15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/redis_cluster_cache_benchmark/spawner.rb', line 15
def run
FileUtils.mkdir_p(@options[:log_dir])
= ("redis-server")
options = @options.each_with_object({}) do |(k,v), d|
unless v.to_s.empty?
d["RCCB_#{k.upcase}"] = v.to_s
end
end
cmd = File.expand_path("../../../bin/worker", __FILE__)
log_path_base = File.expand_path("#{@base_name}.log", @options[:log_dir])
system("rm #{log_path_base}.*")
pids = []
@process_number.times do |idx|
if log_path_base
options["RCCB_LOG_PATH"] = "#{log_path_base}.#{idx + 1}"
end
options["RCCB_WORKER_NO"] = (idx + 1).to_s
pids << Kernel.spawn(options, cmd)
end
pids.each do |pid|
begin
Process.waitpid(pid)
rescue Errno::ECHILD => e
$stderr.puts("WARN [#{e.class}] #{e.message}")
end
end
= ("redis-server")
system("cat #{log_path_base}.* > #{log_path_base}")
system("grep \"\\[GET\\]\" #{log_path_base} > #{log_path_base}.get")
system("grep \"\\[SET\\]\" #{log_path_base} > #{log_path_base}.set")
system("grep \"\\[RSS\\] starting\" #{log_path_base} > #{log_path_base}.rss_starting")
system("grep \"\\[RSS\\] completed\" #{log_path_base} > #{log_path_base}.rss_completed")
File.open(File.expand_path("#{@base_name}.md", @options[:log_dir]), "w") do |f|
calc_array_summary(f, "#{log_path_base}.get", "[GET]", / ([\d\.]+) microsec\Z/, "%3s: %9.3f microsec")
calc_array_summary(f, "#{log_path_base}.set", "[SET]", / ([\d\.]+) microsec\Z/, "%3s: %9.3f microsec")
calc_array_summary(f, "#{log_path_base}.rss_starting" , "memory before start" , / \d+: (\d+) KB\Z/, "%3s: %d KB")
calc_array_summary(f, "#{log_path_base}.rss_completed", "memory after complete", / \d+: (\d+) KB\Z/, "%3s: %d KB")
f.puts
f.puts "redis-server"
f.puts "starting : #{} KB"
f.puts "completed: #{} KB"
end
system("rm #{log_path_base}.*")
end
|