diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-03 21:06:26 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-03 21:06:26 +0000 |
commit | c27a8e87a964c68d04ae6ca65db5bb4a72ca21d9 (patch) | |
tree | daa699d35abc9b17c98d3f1659ad3699510f9cc9 /benchmark | |
parent | ce7c531cbf7e5c14af15e8e153acc9666898a3b5 (diff) |
benchmark/driver.rb: add CPU time measurement targets
"Real" time is too unstable on my systems, hopefully counting
only CPU time can gain more reliable benchmark results.
[ruby-core:87362] [Feature #14815]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark')
-rwxr-xr-x | benchmark/driver.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/benchmark/driver.rb b/benchmark/driver.rb index ac710b8741..0215d7676d 100755 --- a/benchmark/driver.rb +++ b/benchmark/driver.rb @@ -209,6 +209,11 @@ class BenchmarkDriver output({ real: "Execution time (sec)", + utime: "user CPU time", + stime: "system CPU time", + cutime: "user CPU time of children", + cstime: "system CPU time of children", + total: "all CPU time", peak: "Memory usage (peak) (B)", size: "Memory usage (last size) (B)", }[@measure_target]) @@ -332,12 +337,12 @@ class BenchmarkDriver def measure executable, file case @measure_target - when :real + when :real, :utime, :stime, :cutime, :cstime, :total cmd = "#{executable} #{@ruby_arg} #{file}" m = Benchmark.measure{ system(cmd, out: File::NULL) } - result = m.real + result = m.__send__(@measure_target) when :peak, :size tmp = Tempfile.new("benchmark-memory-wrapper-data") wrapper = "#{File.join(__dir__, 'memory_wrapper.rb')} #{tmp.path} #{@measure_target}" @@ -405,7 +410,8 @@ if __FILE__ == $0 o.on('--ruby-arg [ARG]', "Optional argument for ruby"){|a| opt[:ruby_arg] = a } - o.on('--measure-target [TARGET]', 'real (execution time), peak, size (memory)'){|mt| + o.on('--measure-target [TARGET]', + 'real (execution time), peak, size (memory), total'){|mt| opt[:measure_target] = mt.to_sym } o.on('--rawdata-output [FILE]', 'output rawdata'){|r| |