Bug #663: Benchmark.measure outputs different result when executed using command line  "ruby -e  ..."
http://redmine.ruby-lang.org/issues/show/663

Author: Artem Vorozhtsov
Status: Open, Priority: Normal

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.


----------------------------------------
http://redmine.ruby-lang.org