railsbench 0.8.4 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +523 -0
- data/INSTALL +18 -9
- data/Manifest.txt +38 -38
- data/README +6 -6
- data/Rakefile +52 -51
- data/bin/railsbench +48 -50
- data/config/benchmarking.rb +18 -5
- data/install.rb +2 -2
- data/lib/railsbench/perf_utils.rb +114 -0
- data/lib/railsbench/railsbenchmark.rb +9 -2
- data/lib/railsbench/version.rb +2 -2
- data/postinstall.rb +12 -0
- data/script/perf_bench +5 -9
- data/script/perf_comp +0 -4
- data/script/perf_comp_gc +7 -11
- data/script/perf_diff +46 -46
- data/script/perf_diff_gc +39 -75
- data/script/perf_html +0 -4
- data/script/perf_plot +0 -4
- data/script/perf_plot_gc +5 -6
- data/script/perf_prof +61 -44
- data/script/perf_run +31 -26
- data/script/perf_run_gc +38 -44
- data/script/perf_tex +1 -5
- data/script/perf_times +2 -6
- data/script/perf_times_gc +0 -4
- data/script/run_urls +7 -6
- data/setup.rb +1585 -1585
- metadata +3 -3
- data/script/perf_loop +0 -38
@@ -164,15 +164,22 @@ class RailsBenchmark
|
|
164
164
|
|
165
165
|
# support ruby-prof
|
166
166
|
ruby_prof = nil
|
167
|
-
ARGV.each{|arg| ruby_prof=$1 if arg =~ /-ruby_prof=(
|
167
|
+
ARGV.each{|arg| ruby_prof=$1 if arg =~ /-ruby_prof=([^ ]*)/ }
|
168
168
|
begin
|
169
169
|
if ruby_prof
|
170
|
+
# redirect stderr
|
171
|
+
if benchmark_file = ENV['RAILS_BENCHMARK_FILE']
|
172
|
+
$stderr = File.open(benchmark_file, "w")
|
173
|
+
end
|
170
174
|
require 'ruby-prof'
|
171
175
|
RubyProf.clock_mode = RubyProf::WALL_TIME
|
172
176
|
RubyProf.start
|
173
177
|
end
|
174
178
|
rescue LoadError
|
175
179
|
# ruby-prof not available, do nothing
|
180
|
+
$stderr = STDERR
|
181
|
+
$stderr.puts "ruby-prof not available: giving up"
|
182
|
+
exit(-1)
|
176
183
|
end
|
177
184
|
|
178
185
|
# start profiler and trigger data collection if required
|
@@ -203,7 +210,7 @@ class RailsBenchmark
|
|
203
210
|
result = RubyProf.stop
|
204
211
|
# Print a flat profile to text
|
205
212
|
printer = RubyProf::GraphHtmlPrinter.new(result)
|
206
|
-
printer.print(
|
213
|
+
printer.print($stderr, ruby_prof.to_f)
|
207
214
|
end
|
208
215
|
|
209
216
|
delete_test_session
|
data/lib/railsbench/version.rb
CHANGED
data/postinstall.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
if ARGV.include?('--dry-run')
|
5
|
+
include FileUtils::DryRun
|
6
|
+
else
|
7
|
+
include FileUtils::Verbose
|
8
|
+
end
|
9
|
+
|
10
|
+
RAILSBENCH_BASE = File.expand_path(File.dirname(__FILE__)) unless defined?(RAILSBENCH_BASE)
|
11
|
+
|
12
|
+
chmod 0755, Dir["#{RAILSBENCH_BASE}/script/*"]
|
data/script/perf_bench
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
4
4
|
|
5
5
|
unless ENV['RAILS_ROOT']
|
6
|
-
$stderr.puts("\
|
6
|
+
$stderr.puts("\nperf_bench: can't benchmark unless RAILS_ROOT is set")
|
7
7
|
$stderr.puts("\nbenchmarking aborted!")
|
8
8
|
exit 1
|
9
9
|
end
|
@@ -37,13 +37,13 @@ bm(32) do |test|
|
|
37
37
|
benchmarks = YAML::load(File.open(ENV['RAILS_ROOT'] + "/config/benchmarks.yml"))
|
38
38
|
benchmark_name = "default"
|
39
39
|
ARGV.each{ |arg| benchmark_name = $1 if arg =~ /-bm=([a-zA-Z_0-9]+)/ }
|
40
|
-
|
40
|
+
|
41
41
|
RAILS_BENCHMARKER.iterations = ARGV[0].to_i
|
42
42
|
RAILS_BENCHMARKER.url_spec = benchmarks
|
43
43
|
RAILS_BENCHMARKER.setup_test_urls(benchmark_name)
|
44
44
|
RAILS_BENCHMARKER.establish_test_session
|
45
45
|
RAILS_BENCHMARKER.warmup
|
46
|
-
|
46
|
+
|
47
47
|
if ARGV.include?('-mix')
|
48
48
|
RAILS_BENCHMARKER.run_url_mix(test)
|
49
49
|
else
|
@@ -55,12 +55,8 @@ Benchmark::OUTPUT.close unless Benchmark::OUTPUT.nil? || !ENV['RAILS_BENCHMARK_F
|
|
55
55
|
|
56
56
|
__END__
|
57
57
|
|
58
|
-
### Local Variables: ***
|
59
|
-
### mode:ruby ***
|
60
|
-
### End: ***
|
61
|
-
|
62
58
|
# Copyright (C) 2005, 2006 Stefan Kaes
|
63
|
-
#
|
59
|
+
#
|
64
60
|
# This program is free software; you can redistribute it and/or modify
|
65
61
|
# it under the terms of the GNU General Public License as published by
|
66
62
|
# the Free Software Foundation; either version 2 of the License, or
|
@@ -70,7 +66,7 @@ __END__
|
|
70
66
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
71
67
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
72
68
|
# GNU General Public License for more details.
|
73
|
-
#
|
69
|
+
#
|
74
70
|
# You should have received a copy of the GNU General Public License
|
75
71
|
# along with this program; if not, write to the Free Software
|
76
72
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
data/script/perf_comp
CHANGED
data/script/perf_comp_gc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
options = ""
|
4
4
|
if ARGV.length!=2
|
5
|
-
puts "usage: perf_diff_gc file1 file2"
|
5
|
+
$stderr.puts "usage: perf_diff_gc file1 file2"
|
6
6
|
exit 1
|
7
7
|
end
|
8
8
|
files=[]
|
@@ -13,11 +13,11 @@ ARGV.each do |arg|
|
|
13
13
|
if File.stat(fn).readable?
|
14
14
|
files << File.open(fn)
|
15
15
|
else
|
16
|
-
print "file #{fn} is unreadable\n"
|
16
|
+
$stderr.print "file #{fn} is unreadable\n"
|
17
17
|
exit 1
|
18
18
|
end
|
19
19
|
rescue
|
20
|
-
print "file #{fn} does not exist\n"
|
20
|
+
$stderr.print "file #{fn} does not exist\n"
|
21
21
|
exit 1
|
22
22
|
end
|
23
23
|
end
|
@@ -59,12 +59,12 @@ printf "\n %12s %12s %9s %9s %9s %9s\n",
|
|
59
59
|
"c1 mean", "c2 mean", "c1 min", "c2 min", "c1 max", "c2 max"
|
60
60
|
|
61
61
|
number_format = "%12.2f %12.2f %9d %9d %9d %9d"
|
62
|
-
|
62
|
+
|
63
63
|
printf "gc time(ms): #{number_format}\n",
|
64
64
|
gcis[0].time_mean, gcis[1].time_mean,
|
65
65
|
gcis[0].time_min, gcis[1].time_min,
|
66
66
|
gcis[0].time_max, gcis[1].time_max
|
67
|
-
|
67
|
+
|
68
68
|
printf "heap slots : #{number_format}\n",
|
69
69
|
gcis[0].processed_mean, gcis[1].processed_mean,
|
70
70
|
gcis[0].processed_min, gcis[1].processed_min,
|
@@ -74,12 +74,12 @@ printf "live : #{number_format}\n",
|
|
74
74
|
gcis[0].live_mean, gcis[1].live_mean,
|
75
75
|
gcis[0].live_min, gcis[1].live_min,
|
76
76
|
gcis[0].live_max, gcis[1].live_max
|
77
|
-
|
77
|
+
|
78
78
|
printf "freed : #{number_format}\n",
|
79
79
|
gcis[0].freed_mean, gcis[1].freed_mean,
|
80
80
|
gcis[0].freed_min, gcis[1].freed_min,
|
81
81
|
gcis[0].freed_max, gcis[1].freed_max
|
82
|
-
|
82
|
+
|
83
83
|
printf "freelist : #{number_format}\n",
|
84
84
|
gcis[0].freelist_mean, gcis[1].freelist_mean,
|
85
85
|
gcis[0].freelist_min, gcis[1].freelist_min,
|
@@ -88,10 +88,6 @@ printf "freelist : #{number_format}\n",
|
|
88
88
|
|
89
89
|
__END__
|
90
90
|
|
91
|
-
### Local Variables: ***
|
92
|
-
### mode:ruby ***
|
93
|
-
### End: ***
|
94
|
-
|
95
91
|
# Copyright (C) 2005, 2006 Stefan Kaes
|
96
92
|
#
|
97
93
|
# This program is free software; you can redistribute it and/or modify
|
data/script/perf_diff
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
#!/bin/
|
2
|
-
# set -x
|
1
|
+
#!/usr/bin/env ruby
|
3
2
|
|
4
|
-
if
|
5
|
-
|
6
|
-
|
3
|
+
if ARGV.length < 4
|
4
|
+
$stderr.puts 'usage: perf_diff iterations common-options options1 options4 [conf-name1] [conf-name2]'
|
5
|
+
$stderr.puts 'example: perf_diff 100 "-bm=all" "-log" "-nocache" c1 c2'
|
7
6
|
exit 1
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
7
|
+
end
|
8
|
+
|
9
|
+
bindir = File.dirname(__FILE__)
|
10
|
+
require "#{bindir}/../lib/railsbench/perf_utils"
|
11
|
+
|
12
|
+
die("perf_diff: RAILS_ROOT not set") unless ENV['RAILS_ROOT']
|
13
|
+
|
14
|
+
iterations = ARGV[0]
|
15
|
+
common = ARGV[1]
|
16
|
+
options1 = ARGV[2]
|
17
|
+
options2 = ARGV[3]
|
18
|
+
|
19
|
+
benchmark = "default"
|
20
|
+
benchmark = $1 if common =~ /-bm=([^ ]+)/
|
21
|
+
|
22
|
+
file1 = benchmark_file_name(benchmark, ARGV[4], 1)
|
23
|
+
perf_run("perf_diff", iterations, "#{common} #{options1}", file1)
|
24
|
+
puts;puts
|
25
|
+
|
26
|
+
file2 = benchmark_file_name(benchmark, ARGV[5], 2)
|
27
|
+
perf_run("perf_diff", iterations, "#{common} #{options2}", file2)
|
28
|
+
puts;puts
|
29
|
+
|
30
|
+
system("ruby #{bindir}/perf_comp -narrow -skip_urls #{file1} #{file2}")
|
31
|
+
|
32
|
+
__END__
|
33
|
+
|
34
|
+
# Copyright (C) 2005, 2006 Stefan Kaes
|
35
|
+
#
|
36
|
+
# This program is free software; you can redistribute it and/or modify
|
37
|
+
# it under the terms of the GNU General Public License as published by
|
38
|
+
# the Free Software Foundation; either version 2 of the License, or
|
39
|
+
# (at your option) any later version.
|
40
|
+
#
|
41
|
+
# This program is distributed in the hope that it will be useful,
|
42
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
43
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
44
|
+
# GNU General Public License for more details.
|
45
|
+
#
|
46
|
+
# You should have received a copy of the GNU General Public License
|
47
|
+
# along with this program; if not, write to the Free Software
|
48
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
data/script/perf_diff_gc
CHANGED
@@ -1,89 +1,53 @@
|
|
1
|
-
#!/bin/
|
2
|
-
# set -x
|
1
|
+
#!/usr/bin/env ruby
|
3
2
|
|
4
|
-
if
|
5
|
-
|
6
|
-
|
3
|
+
if ARGV.length < 4
|
4
|
+
$stderr.puts 'usage: perf_diff_gc iterations options1 options2 [conf-name1] [conf-name2]'
|
5
|
+
$stderr.puts 'example: perf_diff_gc 100 "-bm=default" "-log" "-nocache" c1 c2'
|
7
6
|
exit 1
|
8
|
-
|
7
|
+
end
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
bindir = File.dirname(__FILE__)
|
10
|
+
require "#{bindir}/../lib/railsbench/perf_utils"
|
12
11
|
|
13
|
-
|
14
|
-
COMMON="$2"
|
15
|
-
OPT1="$3"
|
16
|
-
OPT2="$4"
|
17
|
-
BENCHMARK=""
|
18
|
-
WARMUP="-warmup"
|
12
|
+
die("perf_diff_gc: RAILS_ROOT not set") unless ENV['RAILS_ROOT']
|
19
13
|
|
20
|
-
|
14
|
+
iterations = ARGV[0]
|
15
|
+
common = ARGV[1]
|
16
|
+
options1 = ARGV[2]
|
17
|
+
options2 = ARGV[3]
|
21
18
|
|
19
|
+
benchmark = "default"
|
20
|
+
benchmark = $1 if common =~ /-bm=([^ ]+)/
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
else
|
26
|
-
FILE1="$RAILS_PERF_DATA/perf_run1${BENCHMARK}.gc.txt"
|
27
|
-
fi
|
28
|
-
if [ $# -gt 5 ]; then
|
29
|
-
FILE2="$RAILS_PERF_DATA/${DATE}${BENCHMARK}.$6.gc.txt"
|
30
|
-
else
|
31
|
-
FILE2="$RAILS_PERF_DATA/perf_run2${BENCHMARK}.gc.txt"
|
32
|
-
fi
|
22
|
+
file1 = benchmark_file_name(benchmark, ARGV[4], 1, :gc)
|
23
|
+
perf_run_gc("perf_run_gc", iterations, "#{common} #{options1}", file1)
|
33
24
|
|
34
|
-
|
35
|
-
OLD_RUBY_GC_MALLOC_LIMIT=$RUBY_GC_MALLOC_LIMIT
|
36
|
-
OLD_RUBY_HEAP_FREE_MIN=$RUBY_HEAP_FREE_MIN
|
25
|
+
puts;puts
|
37
26
|
|
38
|
-
|
27
|
+
file2 = benchmark_file_name(benchmark, ARGV[5], 2, :gc)
|
28
|
+
perf_run_gc("perf_run_gc", iterations, "#{common} #{options2}", file2)
|
39
29
|
|
40
|
-
|
41
|
-
for opt in $COMMON $OPT1; do
|
42
|
-
case $opt in
|
43
|
-
-gc=*) patched_gc=${opt#-gc=};;
|
44
|
-
esac
|
45
|
-
done
|
30
|
+
puts;puts
|
46
31
|
|
47
|
-
|
48
|
-
|
49
|
-
else
|
50
|
-
. $RAILS_ROOT/config/${patched_gc}.gc
|
51
|
-
export RUBY_HEAP_MIN_SLOTS RUBY_GC_MALLOC_LIMIT RUBY_HEAP_FREE_MIN
|
52
|
-
fi
|
32
|
+
puts "benchmark comparison data"
|
33
|
+
puts
|
53
34
|
|
54
|
-
|
55
|
-
echo
|
35
|
+
system("ruby #{bindir}/perf_comp_gc #{file1} #{file2}")
|
56
36
|
|
57
|
-
|
58
|
-
&& ruby $BINDIR/perf_times_gc $FILE1
|
59
|
-
echo;echo
|
37
|
+
__END__
|
60
38
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
echo "benchmarking GC performance with options $PERF_OPTIONS"
|
78
|
-
echo
|
79
|
-
|
80
|
-
(RUBY_GC_STATS=1 RUBY_GC_DATA_FILE=$FILE2 ruby $BINDIR/run_urls $PERF_OPTIONS >/dev/null) \
|
81
|
-
&& ruby $BINDIR/perf_times_gc $FILE2
|
82
|
-
echo;echo
|
83
|
-
|
84
|
-
unset RUBY_HEAP_MIN_SLOTS RUBY_GC_MALLOC_LIMIT RUBY_HEAP_FREE_MIN
|
85
|
-
|
86
|
-
echo "benchmark comparison data"
|
87
|
-
echo
|
88
|
-
|
89
|
-
ruby $BINDIR/perf_comp_gc $FILE1 $FILE2
|
39
|
+
# Copyright (C) 2005, 2006 Stefan Kaes
|
40
|
+
#
|
41
|
+
# This program is free software; you can redistribute it and/or modify
|
42
|
+
# it under the terms of the GNU General Public License as published by
|
43
|
+
# the Free Software Foundation; either version 2 of the License, or
|
44
|
+
# (at your option) any later version.
|
45
|
+
#
|
46
|
+
# This program is distributed in the hope that it will be useful,
|
47
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
48
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
49
|
+
# GNU General Public License for more details.
|
50
|
+
#
|
51
|
+
# You should have received a copy of the GNU General Public License
|
52
|
+
# along with this program; if not, write to the Free Software
|
53
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
data/script/perf_html
CHANGED
data/script/perf_plot
CHANGED
data/script/perf_plot_gc
CHANGED
@@ -16,6 +16,7 @@ labels = %w()
|
|
16
16
|
perf_data = []
|
17
17
|
graph_type = Gruff::StackedBar
|
18
18
|
graph_width = 1400
|
19
|
+
ignored_object_types = %w(NODE STRING)
|
19
20
|
|
20
21
|
ARGV.each do |arg|
|
21
22
|
case arg
|
@@ -29,6 +30,8 @@ ARGV.each do |arg|
|
|
29
30
|
# title = $1 unless $1.strip.empty?
|
30
31
|
# when /^-names=(.+)$/
|
31
32
|
# names = $1.split(',')
|
33
|
+
when /^-ignore=(.*)$/
|
34
|
+
ignored_object_types = $1.split(',').map(&:upcase)
|
32
35
|
else
|
33
36
|
files << File.open_or_die(arg)
|
34
37
|
names[files.length-1] ||= File.basename(arg)
|
@@ -71,7 +74,7 @@ g.labels = Hash[* (0...gc_count_max).map{|i| [2*i, i.to_s]}.flatten ]
|
|
71
74
|
puts g.labels.inspect
|
72
75
|
|
73
76
|
object_types.each do |ot|
|
74
|
-
next if ot
|
77
|
+
next if ignored_object_types.include?(ot)
|
75
78
|
data = []
|
76
79
|
gc_count_max.times do |gc_index|
|
77
80
|
for gci in gcis
|
@@ -81,7 +84,7 @@ object_types.each do |ot|
|
|
81
84
|
data << ((map_at_this_gc && map_at_this_gc[ot]) || 0)
|
82
85
|
end
|
83
86
|
end
|
84
|
-
puts "#{ot}: #{data.inspect}"
|
87
|
+
# puts "#{ot}: #{data.inspect}"
|
85
88
|
g.data(ot, data)
|
86
89
|
end
|
87
90
|
|
@@ -90,10 +93,6 @@ g.write
|
|
90
93
|
|
91
94
|
__END__
|
92
95
|
|
93
|
-
### Local Variables: ***
|
94
|
-
### mode:ruby ***
|
95
|
-
### End: ***
|
96
|
-
|
97
96
|
# Copyright (C) 2005, 2006 Stefan Kaes
|
98
97
|
#
|
99
98
|
# This program is free software; you can redistribute it and/or modify
|