Project

General

Profile

Actions

Bug #663

closed

Benchmark.measure outputs different result when executed using command line "ruby -e ..."

Added by greck (Artem Vorozhtsov) over 15 years ago. Updated about 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
[ruby-core:19388]

Description

=begin
I've tested it on :

  • ruby 1.8.6 (2008-03-03 patchlevel 114) [i686-linux]
  • ruby 1.8.5 (2006-08-25) [i386-linux]

Sorry, I've not tested it against 1.9 and 1.8.7.

[artem@dev bm_test]$ cat a.c
int main() {
int i = 0, k = 0, n = 1000000000;
for(i = 0 ; i< n; i++){ k += i*i; }
return k;
}
[artem@dev bm_test]$ make a
cc a.c -o a
[artem@dev bm_test]$ ruby -rbenchmark -e "puts Benchmark.measure{ ./a }"
0.000000 0.000000 0.000000 ( 0.000011)
[artem@dev bm_test]$ echo 'puts Benchmark.measure{ ./a }' > b.rb
[artem@dev bm_test]$ cat b.rb
puts Benchmark.measure{ ./a }
[artem@dev bm_test]$ ruby -rbenchmark b.rb
0.000000 0.000000 4.660000 ( 4.652781)

Bugs:

  1. "ruby -e" : "total" is zero
  2. "ruby -e" : "real" is too small (should be ~ 4 seconds)
  3. "ruby" : "total" is not equal to "user" + "system" in the last example.
    =end
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0