mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
ce7c531cbf
commit
c27a8e87a9
1 changed files with 9 additions and 3 deletions
|
@ -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|
|
||||
|
|
Loading…
Reference in a new issue