19
与Ruby的基准测试模块做实验......Ruby基准模块:“用户”,“系统”和“真实”的含义?
>> Benchmark.bm(7) { |b| b.report('Report:') { s = '' ; 10000.times { s += 'a' } } }
user system total real
Report: 0.150000 0.010000 0.160000 ( 0.156361)
什么是“用户”,“系统”和“真实”的含义?
优秀。谢谢。 – Ethan 2009-10-23 23:36:32
@jorg基准测试的Ruby文档是否出现错误,因为它们显示的实时比总时间短得多?资料来源:http://ruby-doc.org/stdlib-1.9.3/libdoc/benchmark/rdoc/Benchmark.html – rscott 2012-08-28 14:27:09
@rscott:用户,系统和总数是指所有内核之间的时间总和,而真正的只是字面总时间。因此,如果代码运行在多核系统上,前三者中的任何一个都可以超过后者。 – Sparhawk 2013-03-12 23:59:10