path: root/benchmark
diff options
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-03 21:06:26 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-03 21:06:26 (GMT)
commitc27a8e87a964c68d04ae6ca65db5bb4a72ca21d9 (patch)
treedaa699d35abc9b17c98d3f1659ad3699510f9cc9 /benchmark
parentce7c531cbf7e5c14af15e8e153acc9666898a3b5 (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:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark')
1 files changed, 9 insertions, 3 deletions
diff --git a/benchmark/driver.rb b/benchmark/driver.rb
index ac710b8..0215d76 100755
--- a/benchmark/driver.rb
+++ b/benchmark/driver.rb
@@ -209,6 +209,11 @@ class BenchmarkDriver
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)",
@@ -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 ="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|