Skip to content

Commit

Permalink
use io (stderr chanel) instead of file on benchmark (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
waghanza committed Sep 11, 2018
1 parent 41f9406 commit bbc97e7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 deletions.
6 changes: 2 additions & 4 deletions tools/pipeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
-- percentile : 99.999

done = function(summary, latency, requests)
file = io.open('/tmp/which_is_the_fastest.out', 'w')

out = {
summary.duration,
Expand All @@ -41,10 +40,9 @@ done = function(summary, latency, requests)

for key, value in pairs(out) do
if key > 1 then
file:write(",")
io.stderr:write(",")
end
file:write(string.format("%d", value))
io.stderr:write(string.format("%d", value))
end

file.close(file)
end
6 changes: 2 additions & 4 deletions tools/pipeline_post.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"
-- percentile : 99.999

done = function(summary, latency, requests)
file = io.open('/tmp/which_is_the_fastest.out', 'w')

out = {
summary.duration,
Expand All @@ -45,10 +44,9 @@ done = function(summary, latency, requests)

for key, value in pairs(out) do
if key > 1 then
file:write(",")
io.stderr:write(",")
end
file:write(string.format("%d", value))
io.stderr:write(string.format("%d", value))
end

file.close(file)
end
27 changes: 10 additions & 17 deletions tools/src/benchmarker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -348,23 +348,16 @@ ranks_by_requests.each do |framework|
puts_markdown "| %-25s | %-25s | %.2f | %.2f MB |" % [framework.target.lang, framework.target.name, result.request.per_second, (result.request.bytes/1000000)], m_lines, true
end

ranks_by_requests.each do |framework|
raw = store.get("#{framework.target.lang}:#{framework.target.name}").as(String)
result = Result.from_json(raw)
puts_markdown "| %-25s | %-25s | %.2f | %.2f MB |" % [framework.target.lang, framework.target.name, result.request.per_second, (result.request.bytes/1000000)], m_lines, true
end


if record
path = File.expand_path("../../../README.md", __FILE__)
tag_from = "<!-- Result from here -->"
tag_till = "<!-- Result till here -->"
m_lines.insert(0, tag_from)
m_lines.push(tag_till)
prev_readme = File.read(path)
next_readme = prev_readme.gsub(
/\<!--\sResult\sfrom\shere\s-->[\s\S]*?<!--\sResult\still\shere\s-->/,
m_lines.join('\n'))
if record
path = File.expand_path("../../../README.md", __FILE__)
tag_from = "<!-- Result from here -->"
tag_till = "<!-- Result till here -->"
m_lines.insert(0, tag_from)
m_lines.push(tag_till)
prev_readme = File.read(path)
next_readme = prev_readme.gsub(
/\<!--\sResult\sfrom\shere\s-->[\s\S]*?<!--\sResult\still\shere\s-->/,
m_lines.join('\n'))

File.write(path, next_readme)
end
9 changes: 5 additions & 4 deletions tools/src/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ class Client

def run
if @method == "POST"
`wrk -H 'Connection: keep-alive' --latency -d #{@duration}s -s #{PIPELINE_POST} -c #{@connections.to_i} --timeout 8 -t #{@threads} #{@url}`
command = "wrk -H 'Connection: keep-alive' --latency -d #{@duration}s -s #{PIPELINE_POST} -c #{@connections.to_i} --timeout 8 -t #{@threads} #{@url}"
else
`wrk -H 'Connection: keep-alive' --latency -d #{@duration}s -s #{PIPELINE_GET} -c #{@connections.to_i} --timeout 8 -t #{@threads} #{@url}`
command = "wrk -H 'Connection: keep-alive' --latency -d #{@duration}s -s #{PIPELINE_GET} -c #{@connections.to_i} --timeout 8 -t #{@threads} #{@url}"
end
io = IO::Memory.new
Process.run(command, shell: true, error: io)

result = File.read("/tmp/which_is_the_fastest.out").split(",")
File.delete("/tmp/which_is_the_fastest.out")
result = io.to_s.split(",")

data = JSON.build do |json|
json.object do
Expand Down

0 comments on commit bbc97e7

Please sign in to comment.