Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ And with gnuplot we generate graphs in `.SVG` files and you can see with
Each direcyory have a specific test case.

- Primary Key: Test the best data type for this purpose.
- Random:
- Random: Generate only random data.
- Row Format: Compressed VS Dynamic

## Consideration

-
-
-
-
- El número de TPS or QPS será proporcional al rendimiento ofrecido por la CPU y los IOPS entre otros.

## Install

```bash
brew install mysql@5.7
brew install sysbench
brew install gnuplot
```

## Requirement

Expand Down
4 changes: 4 additions & 0 deletions row_format/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Row Format

![Compressed](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/row_format/compressed/compressed.svg?sanitize=true)
![Dynamic](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/row_format/dynamic/dynamic.svg?sanitize=true)
28 changes: 28 additions & 0 deletions row_format/compressed/compressed.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/local/bin/gnuplot
reset

# Titles & Axis Labels
set title 'Benchmark ROW_FORMAT with COMPRESSED type by tps/qps'
set xlabel 'Duration (s)'
set ylabel 'Transactions and Queries (tps/qps)'

# Output
set terminal svg size 800,380 font 'Verdana,10'
set output 'compressed.svg'

# Grid
set grid
set key outside top right vertical
set tics out nomirror

# Lines
set style data line
set style line 1 linecolor rgb '#0060ad'
set style line 2 linecolor rgb '#3ADF00'

# Input data
set datafile separator ";"

# TPS
plot 'insert.csv' using 0:2 linestyle 1 title 'Inserts', \
'select.csv' using 0:2 linestyle 2 title 'Select'
35 changes: 35 additions & 0 deletions row_format/compressed/compressed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# encoding: UTF-8

./insert.lua \
--mysql-password=sbtest \
prepare

./insert.lua \
--mysql-password=sbtest \
--threads=1 \
--report-interval=1 \
--max-time=300 \
run > insert.log

./select.lua \
--mysql-password=sbtest \
--threads=1 \
--report-interval=1 \
--max-time=300 \
--thread-init-timeout=120 \
run > select.log

./insert.lua \
--mysql-password=sbtest \
cleanup

cat insert.log | egrep '\d+\;\d+' > insert.csv
cat select.log | egrep '\d+\;\d+' > select.csv

./compressed.pg

open -a "Gapplin" compressed.svg

rm insert{.log,.csv}
rm select{.log,.csv}
346 changes: 346 additions & 0 deletions row_format/compressed/compressed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions row_format/compressed/insert.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env sysbench

local c_value_template = "###########-###########-###########-" ..
"###########-###########-###########-" ..
"###########-###########-###########-" ..
"###########"

function prepare()
local drv = sysbench.sql.driver()
local con = drv:connect()

con:query(string.format([[
CREATE TABLE IF NOT EXISTS sbtest (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
c VARCHAR(120) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB ROW_FORMAT=COMPRESSED
]]))
end

function cleanup()
local drv = sysbench.sql.driver()
local con = drv:connect()

con:query("DROP TABLE IF EXISTS sbtest")
end

function thread_init()
drv = sysbench.sql.driver()
con = drv:connect()
end

function get_c_value()
return sysbench.rand.string(c_value_template)
end

function event ()
query = string.format("INSERT INTO sbtest (c) VALUES ('%s')", get_c_value())

con:query(query)
end

function thread_done()
con:disconnect()
end

function sysbench.hooks.report_intermediate(stat)
drv = sysbench.sql.driver()
con = drv:connect()

print(string.format("%.0f;%d",
stat.time_total,
stat.events
))
end

33 changes: 33 additions & 0 deletions row_format/compressed/select.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env sysbench

function thread_init()
drv = sysbench.sql.driver()
con = drv:connect()
end

function event ()
-- Maybe to optimize the second arg on math.random(1, 460000)
-- is good to take first select max(id) from sbtest; and round.
--
local rnd = math.random(1, 460000)
local sql = [[
SELECT SQL_NO_CACHE *
FROM sbtest
WHERE id = %d
]]

con:query(string.format(sql, rnd))
end

function thread_done()
con:disconnect()
end

function sysbench.hooks.report_intermediate(stat)
local seconds = stat.time_interval

print(string.format("%.0f;%d",
stat.time_total,
stat.events
))
end
28 changes: 28 additions & 0 deletions row_format/dynamic/dynamic.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/local/bin/gnuplot
reset

# Titles & Axis Labels
set title 'Benchmark ROW_FORMAT with DYNAMIC type by tps/qps'
set xlabel 'Duration (s)'
set ylabel 'Transactions and Queries (tps/qps)'

# Output
set terminal svg size 800,380 font 'Verdana,10'
set output 'dynamic.svg'

# Grid
set grid
set key outside top right vertical
set tics out nomirror

# Lines
set style data line
set style line 1 linecolor rgb '#0060ad'
set style line 2 linecolor rgb '#3ADF00'

# Input data
set datafile separator ";"

# TPS
plot 'insert.csv' using 0:2 linestyle 1 title 'Inserts', \
'select.csv' using 0:2 linestyle 2 title 'Select'
35 changes: 35 additions & 0 deletions row_format/dynamic/dynamic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# encoding: UTF-8

./insert.lua \
--mysql-password=sbtest \
prepare

./insert.lua \
--mysql-password=sbtest \
--threads=1 \
--report-interval=1 \
--max-time=300 \
run > insert.log

./select.lua \
--mysql-password=sbtest \
--threads=1 \
--report-interval=1 \
--max-time=300 \
--thread-init-timeout=120 \
run > select.log

./insert.lua \
--mysql-password=sbtest \
cleanup

cat insert.log | egrep '\d+\;\d+' > insert.csv
cat select.log | egrep '\d+\;\d+' > select.csv

./dynamic.pg

open -a "Gapplin" dynamic.svg

rm insert{.log,.csv}
rm select{.log,.csv}
Loading