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/INSTALL CHANGED
@@ -5,7 +5,7 @@ INSTALLATION
5
5
  STEP 1: installing railsbench and PATH modifcation
6
6
 
7
7
  If you obtained and installed railsbench as a gem, a script called
8
- railsbench is available in you Ruby bin directory. railsbench is a
8
+ railsbench is available in your Ruby bin directory. railsbench is a
9
9
  simple driver for the railsbench scripts, which are located in the gem
10
10
  installation directory. Example:
11
11
 
@@ -16,10 +16,18 @@ path. The exact place can be found running
16
16
 
17
17
  railsbench base
18
18
 
19
- which prints the script directory path. After that change, individual
20
- commands can be run directly:
19
+ which prints the script directory path. Another option is to run
21
20
 
22
- railsbench perf_run 100 -bm=all
21
+ eval `railsbench path`
22
+
23
+ Since gem packages don't support running postinstall scripts, you will
24
+ need to make the scripts executable by running
25
+
26
+ sudo railsbench postinstall
27
+
28
+ After performing these steps, individual commands can be run directly:
29
+
30
+ perf_run 100 -bm=all
23
31
 
24
32
  The environment variable RAILS_ROOT must be set and point to your apps
25
33
  base directory, in order for railsbench to work properly.
@@ -41,15 +49,16 @@ Manual installation:
41
49
 
42
50
  Automatic installation:
43
51
 
44
- Run railsbench install. This will perform all of the above steps and
45
- create a section in database.yml pointing to your development
46
- database. In case you are worrying about possible results, you can
47
- call railsbench install --dry-run first.
52
+ Run 'railsbench install'. This will perform all of the above steps
53
+ and create a configuration named 'benchmarking' in database.yml
54
+ pointing to your development database. In case you are worrying
55
+ about possible results, you can call railsbench install --dry-run
56
+ first.
48
57
 
49
58
 
50
59
  STEP 3: optional (but highly recommended)
51
60
 
52
61
  Patch the ruby garbage collector using rubygc18{45}.patch, depending
53
62
  on your ruby version. Recompile ruby and copy the ruby binary and
54
- shared libs to where it was previously installed. See GCPATCH for
63
+ shared libs to where they were previously installed. See GCPATCH for
55
64
  details on how to influence the patched ruby gc.
data/Manifest.txt CHANGED
@@ -1,38 +1,38 @@
1
- BUGS
2
- CHANGELOG
3
- INSTALL
4
- install.rb
5
- LICENSE
6
- Manifest.txt
7
- README
8
- Rakefile
9
- setup.rb
10
- ruby184gc.patch
11
- ruby185gc.patch
12
- bin/railsbench
13
- lib/railsbench/version.rb
14
- lib/railsbench/gc_info.rb
15
- lib/railsbench/perf_info.rb
16
- lib/railsbench/perf_utils.rb
17
- lib/railsbench/write_headers_only.rb
18
- lib/railsbench/railsbenchmark.rb
19
- lib/benchmark.rb
20
- script/perf_bench
21
- script/perf_comp
22
- script/perf_comp_gc
23
- script/perf_diff
24
- script/perf_diff_gc
25
- script/perf_html
26
- script/perf_loop
27
- script/perf_plot
28
- script/perf_plot_gc
29
- script/perf_prof
30
- script/perf_run
31
- script/perf_run_gc
32
- script/perf_tex
33
- script/perf_times
34
- script/perf_times_gc
35
- script/run_urls
36
- config/benchmarking.rb
37
- config/benchmarks.rb
38
- config/benchmarks.yml
1
+ BUGS
2
+ CHANGELOG
3
+ INSTALL
4
+ install.rb
5
+ postinstall.rb
6
+ LICENSE
7
+ Manifest.txt
8
+ README
9
+ Rakefile
10
+ setup.rb
11
+ ruby184gc.patch
12
+ ruby185gc.patch
13
+ bin/railsbench
14
+ lib/railsbench/version.rb
15
+ lib/railsbench/gc_info.rb
16
+ lib/railsbench/perf_info.rb
17
+ lib/railsbench/perf_utils.rb
18
+ lib/railsbench/write_headers_only.rb
19
+ lib/railsbench/railsbenchmark.rb
20
+ lib/benchmark.rb
21
+ script/perf_bench
22
+ script/perf_comp
23
+ script/perf_comp_gc
24
+ script/perf_diff
25
+ script/perf_diff_gc
26
+ script/perf_html
27
+ script/perf_plot
28
+ script/perf_plot_gc
29
+ script/perf_prof
30
+ script/perf_run
31
+ script/perf_run_gc
32
+ script/perf_tex
33
+ script/perf_times
34
+ script/perf_times_gc
35
+ script/run_urls
36
+ config/benchmarking.rb
37
+ config/benchmarks.rb
38
+ config/benchmarks.yml
data/README CHANGED
@@ -1,13 +1,13 @@
1
- Railsbench is a small collection of ruby and shell scripts which make
2
- measuring raw performance of rails apps a snap. All tests are run from
3
- the command prompt making performance regression testing easy.
1
+ Railsbench is a small collection of ruby scripts which make measuring
2
+ raw performance of rails apps a snap. All tests are run from the
3
+ command prompt, making performance regression testing easy.
4
4
 
5
5
  In addition, a patch for the ruby garbage collector is provided, which
6
6
  can be used to reduce the amount of time spent doing garbage
7
7
  collection, trading memory for speed, as usual (see file GCPATCH for
8
- details). In addition, applying the patch will enhance performance
9
- data obtained from the various scripts (and some won't run at all
10
- without the patch).
8
+ details). Applying the patch will enhance performance data obtained
9
+ from the various scripts (and some won't run at all without the
10
+ patch).
11
11
 
12
12
  This software was written and conceived by Stefan Kaes. The author can
13
13
  be reached via email: <skaes@gmx.net>. Please send comments, bug
data/Rakefile CHANGED
@@ -1,51 +1,52 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'rake/clean'
4
- require 'rake/testtask'
5
- require 'rake/packagetask'
6
- require 'rake/gempackagetask'
7
- require 'rake/rdoctask'
8
- require 'rake/contrib/rubyforgepublisher'
9
- require 'fileutils'
10
- require 'hoe'
11
- include FileUtils
12
- require File.join(File.dirname(__FILE__), 'lib', 'railsbench', 'version')
13
-
14
- AUTHOR = "Stefan Kaes" # can also be an array of Authors
15
- EMAIL = "skaes@gmx.net"
16
- DESCRIPTION = "rails benchmarking tools"
17
- GEM_NAME = "railsbench" # what ppl will type to install your gem
18
- RUBYFORGE_PROJECT = "railsbench" # The unix name for your project
19
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
20
- RELEASE_TYPES = %w(gem tar zip) # can use: gem, tar, zip
21
-
22
-
23
- NAME = "railsbench"
24
- REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
25
- VERS = (ENV['VERSION'] ||= (Railsbench::VERSION::STRING + (REV ? ".#{REV}" : "")))
26
- CLEAN.include ['**/.*.sw?', '*.gem', '.config']
27
- RDOC_OPTS = ['--quiet', '--title', "railsbench documentation",
28
- "--opname", "index.html",
29
- "--line-numbers",
30
- "--main", "README",
31
- "--inline-source"]
32
-
33
- # Generate all the Rake tasks
34
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
35
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
36
- p.author = AUTHOR
37
- p.description = DESCRIPTION
38
- p.email = EMAIL
39
- p.summary = DESCRIPTION
40
- p.url = HOMEPATH
41
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
42
- p.test_globs = ["test/**/*_test.rb"]
43
- p.clean_globs = CLEAN #An array of file patterns to delete on clean.
44
- p.need_zip = true
45
- p.spec_extras = {:has_rdoc => false}
46
-
47
- # == Optional
48
- #p.changes - A description of the release's latest changes.
49
- #p.extra_deps - An array of rubygem dependencies.
50
- #p.spec_extras - A hash of extra values to set in the gemspec.
51
- end
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'fileutils'
10
+ require 'hoe'
11
+ include FileUtils
12
+ require File.join(File.dirname(__FILE__), 'lib', 'railsbench', 'version')
13
+
14
+ AUTHOR = "Stefan Kaes" # can also be an array of Authors
15
+ EMAIL = "skaes@gmx.net"
16
+ DESCRIPTION = "rails benchmarking tools"
17
+ GEM_NAME = "railsbench" # what ppl will type to install your gem
18
+ RUBYFORGE_PROJECT = "railsbench" # The unix name for your project
19
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
20
+ RELEASE_TYPES = %w(gem tar zip) # can use: gem, tar, zip
21
+
22
+
23
+ NAME = "railsbench"
24
+ REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
25
+ VERS = (ENV['VERSION'] ||= (Railsbench::VERSION::STRING + (REV ? ".#{REV}" : "")))
26
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config']
27
+ RDOC_OPTS = ['--quiet', '--title', "railsbench documentation",
28
+ "--opname", "index.html",
29
+ "--line-numbers",
30
+ "--main", "README",
31
+ "--inline-source"]
32
+
33
+ # Generate all the Rake tasks
34
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
35
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
36
+ p.author = AUTHOR
37
+ p.description = DESCRIPTION
38
+ p.email = EMAIL
39
+ p.summary = DESCRIPTION
40
+ p.url = HOMEPATH
41
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
42
+ p.test_globs = ["test/**/*_test.rb"]
43
+ p.clean_globs = CLEAN #An array of file patterns to delete on clean.
44
+ p.need_zip = true
45
+ p.spec_extras = {:has_rdoc => false}
46
+ p.changes = `cat latest_changes`
47
+
48
+ # == Optional
49
+ #p.changes - A description of the release's latest changes.
50
+ #p.extra_deps - An array of rubygem dependencies.
51
+ #p.spec_extras - A hash of extra values to set in the gemspec.
52
+ end
data/bin/railsbench CHANGED
@@ -1,50 +1,48 @@
1
- #!/usr/bin/env ruby
2
-
3
- CMDS = %w(
4
- base
5
- perf_comp
6
- perf_comp_gc
7
- perf_diff
8
- perf_diff_gc
9
- perf_html
10
- perf_plot
11
- perf_plot_gc
12
- perf_prof
13
- perf_run
14
- perf_run_gc
15
- perf_tex
16
- perf_times
17
- perf_times_gc
18
- install
19
- run_urls
20
- )
21
-
22
- cmd = ARGV.shift
23
- unless CMDS.include? cmd
24
- $stderr.puts "railsbench: unkown command: #{cmd}"
25
- $stderr.puts "use one of: #{CMDS.sort.join(', ')}"
26
- exit 1
27
- end
28
-
29
- RAILSBENCH_BASE = File.expand_path(File.dirname(__FILE__) + '/..')
30
-
31
- def quoted_args
32
- ARGV.map{|s| "'#{s}'" }.join(' ')
33
- end
34
-
35
- case cmd
36
- when 'base'
37
- puts "railsbench is installed in: #{RAILSBENCH_BASE}"
38
- puts "load path: #{$:.join("\n")}"
39
- exit
40
- else
41
- if cmd == 'install'
42
- script = RAILSBENCH_BASE + '/install.rb'
43
- else
44
- script = RAILSBENCH_BASE + '/script/' + cmd
45
- end
46
- command = "sh -c \"#{script} #{quoted_args}\""
47
- # puts command
48
- exec(command)
49
- end
50
-
1
+ #!/usr/bin/env ruby
2
+
3
+ RAILSBENCH_CMDS = %w(
4
+ base
5
+ install
6
+ path
7
+ perf_comp
8
+ perf_comp_gc
9
+ perf_diff
10
+ perf_diff_gc
11
+ perf_html
12
+ perf_plot
13
+ perf_plot_gc
14
+ perf_prof
15
+ perf_run
16
+ perf_run_gc
17
+ perf_tex
18
+ perf_times
19
+ perf_times_gc
20
+ postinstall
21
+ run_urls
22
+ ).inject({}){ |h, cmd| h[cmd] = cmd; h[cmd.sub('perf_', '')] = cmd; h}
23
+
24
+ cmd = ARGV.shift
25
+ unless real_cmd = RAILSBENCH_CMDS[cmd]
26
+ $stderr.puts "railsbench: unknown command: #{cmd}"
27
+ $stderr.puts "use one of: #{RAILSBENCH_CMDS.keys.sort.join(', ')}"
28
+ exit 1
29
+ end
30
+
31
+ RAILSBENCH_BASE = File.expand_path(File.dirname(__FILE__) + '/..')
32
+
33
+ case real_cmd
34
+ when 'base'
35
+ puts "railsbench is installed in: #{RAILSBENCH_BASE}"
36
+ exit
37
+ when 'path'
38
+ puts "PATH=#{RAILSBENCH_BASE}/script:$PATH"
39
+ exit
40
+ when 'install', 'postinstall'
41
+ load "#{RAILSBENCH_BASE}/#{real_cmd}.rb"
42
+ else
43
+ unless ENV['RAILS_ROOT']
44
+ $stderr.puts "railsbench: RAILS_ROOT not set"
45
+ exit 1
46
+ end
47
+ load "#{RAILSBENCH_BASE}/script/#{real_cmd}"
48
+ end
@@ -1,8 +1,21 @@
1
- Dependencies.mechanism = :require
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
2
 
3
- ActionController::Base.consider_all_requests_local = false
4
- ActionController::Base.perform_caching = true
3
+ # Code is not reloaded between requests
4
+ config.cache_classes = true
5
5
 
6
- ActionView::Base.cache_template_loading = true
7
- ActionController::Base.view_controller_internals = false
6
+ # Use a different logger for distributed setups
7
+ # config.logger = SyslogLogger.new
8
8
 
9
+ # Full error reports are disabled and caching is turned on
10
+ config.action_controller.consider_all_requests_local = false
11
+ config.action_controller.perform_caching = true
12
+ config.action_view.cache_template_loading = true
13
+
14
+ # we don't want to see controller internals
15
+ config.action_controller.view_controller_internals = false
16
+
17
+ # Enable serving of images, stylesheets, and javascripts from an asset server
18
+ # config.action_controller.asset_host = "http://assets.example.com"
19
+
20
+ # Disable delivery errors if you bad email addresses should just be ignored
21
+ # config.action_mailer.raise_delivery_errors = false
data/install.rb CHANGED
@@ -44,7 +44,7 @@ __END__
44
44
  ### End: ***
45
45
 
46
46
  # Copyright (C) 2005, 2006 Stefan Kaes
47
- #
47
+ #
48
48
  # This program is free software; you can redistribute it and/or modify
49
49
  # it under the terms of the GNU General Public License as published by
50
50
  # the Free Software Foundation; either version 2 of the License, or
@@ -54,7 +54,7 @@ __END__
54
54
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
55
55
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56
56
  # GNU General Public License for more details.
57
- #
57
+ #
58
58
  # You should have received a copy of the GNU General Public License
59
59
  # along with this program; if not, write to the Free Software
60
60
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -63,3 +63,117 @@ def truncate(text, length = 32, truncate_string = "...")
63
63
  chars.length > length ? chars[0..(length - l)].join + truncate_string : text
64
64
  end
65
65
  end
66
+
67
+ RAILSBENCH_BINDIR = File.expand_path(File.dirname(__FILE__) + "/../../script")
68
+
69
+ def enable_gc_stats(file)
70
+ ENV['RUBY_GC_STATS'] = "1"
71
+ ENV['RUBY_GC_DATA_FILE'] = file
72
+ end
73
+
74
+ def disable_gc_stats
75
+ ENV.delete 'RUBY_GC_STATS'
76
+ ENV.delete 'RUBY_GC_DATA_FILE'
77
+ end
78
+
79
+ def unset_gc_variables
80
+ %w(RUBY_HEAP_MIN_SLOTS RUBY_GC_MALLOC_LIMIT RUBY_HEAP_FREE_MIN).each{|v| ENV.delete v}
81
+ end
82
+
83
+ def load_gc_variables(gc_spec)
84
+ File.open_or_die("#{ENV['RAILS_ROOT']}/config/#{gc_spec}.gc").each_line do |line|
85
+ ENV[$1] = $2 if line =~ /^(.*)=(.*)$/
86
+ end
87
+ end
88
+
89
+ def set_gc_variables(argv)
90
+ gc_spec = nil
91
+ argv.each{|arg| gc_spec=$1 if arg =~ /-gc=([^ ]*)/}
92
+
93
+ if gc_spec
94
+ load_gc_variables(gc_spec)
95
+ else
96
+ unset_gc_variables
97
+ end
98
+ end
99
+
100
+ def benchmark_file_name(benchmark, config_name, prefix=nil, suffix=nil)
101
+ perf_data_dir = (ENV['RAILS_PERF_DATA'] ||= ENV['HOME'])
102
+ date = Time.now.strftime '%m-%d'
103
+ suffix = ".#{suffix}" if suffix
104
+ ENV['RAILS_BENCHMARK_FILE'] =
105
+ if config_name
106
+ "#{perf_data_dir}/#{date}.#{benchmark}.#{config_name}#{suffix}.txt"
107
+ else
108
+ "#{perf_data_dir}/perf_run#{prefix}.#{benchmark}#{suffix}.txt"
109
+ end
110
+ end
111
+
112
+ def quote_arguments(argv)
113
+ argv.map{|a| a.include?(' ') ? "'#{a}'" : a.to_s}.join(' ')
114
+ end
115
+
116
+ def perf_run(script, iterations, options, raw_data_file)
117
+ perf_runs = (ENV['RAILS_PERF_RUNS'] ||= "3").to_i
118
+
119
+ disable_gc_stats
120
+ set_gc_variables([iterations, options])
121
+
122
+ perf_options = "#{iterations} #{options}"
123
+ null = (RUBY_PLATFORM =~ /win32/i) ? 'nul' : '/dev/null'
124
+
125
+ perf_cmd = "ruby #{RAILSBENCH_BINDIR}/perf_bench #{perf_options}"
126
+ print_cmd = "ruby #{RAILSBENCH_BINDIR}/perf_times #{raw_data_file}"
127
+
128
+ puts "benchmarking #{perf_runs} runs with options #{perf_options}"
129
+
130
+ File.open(raw_data_file, "w"){ |f| f.puts perf_cmd }
131
+ perf_runs.times do
132
+ system("#{perf_cmd} >#{null}") || die("#{script}: #{perf_cmd} returned #{$?}")
133
+ end
134
+ File.open(raw_data_file, "a" ){|f| f.puts }
135
+
136
+ unset_gc_variables
137
+ system(print_cmd) || die("#{script}: #{print_cmd} returned #{$?}")
138
+ end
139
+
140
+ def perf_run_gc(script, iterations, options, raw_data_file)
141
+ warmup = "-warmup"
142
+ warmup = "" if options =~ /-warmup/
143
+
144
+ enable_gc_stats(raw_data_file)
145
+ set_gc_variables([options])
146
+
147
+ perf_options = "#{iterations} #{warmup} #{options}"
148
+ null = (RUBY_PLATFORM =~ /win32/) ? 'nul' : '/dev/null'
149
+
150
+ perf_cmd = "ruby #{RAILSBENCH_BINDIR}/run_urls #{perf_options} >#{null}"
151
+ print_cmd = "ruby #{RAILSBENCH_BINDIR}/perf_times_gc #{raw_data_file}"
152
+
153
+ puts "benchmarking GC performance with options #{perf_options}"
154
+ puts
155
+
156
+ system(perf_cmd) || die("#{script}: #{perf_cmd} returned #{$?}")
157
+
158
+ disable_gc_stats
159
+ unset_gc_variables
160
+ system(print_cmd) || die("#{script}: #{print_cmd} returned #{$?}")
161
+ end
162
+
163
+ __END__
164
+
165
+ # Copyright (C) 2005, 2006 Stefan Kaes
166
+ #
167
+ # This program is free software; you can redistribute it and/or modify
168
+ # it under the terms of the GNU General Public License as published by
169
+ # the Free Software Foundation; either version 2 of the License, or
170
+ # (at your option) any later version.
171
+ #
172
+ # This program is distributed in the hope that it will be useful,
173
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
174
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
175
+ # GNU General Public License for more details.
176
+ #
177
+ # You should have received a copy of the GNU General Public License
178
+ # along with this program; if not, write to the Free Software
179
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA