[#8815] Segfault in libc strlen, via rb_str_new2 — "Sean E. Russell" <ser@...>

Howdy,

12 messages 2006/09/09
[#8817] Re: Segfault in libc strlen, via rb_str_new2 — Eric Hodel <drbrain@...7.net> 2006/09/09

On Sep 8, 2006, at 10:10 PM, Sean E. Russell wrote:

suprising benchmark

From: Ondrej Bilka <neleai@...>
Date: 2006-09-02 09:18:29 UTC
List: ruby-core #8774
I wondered what gives you optimalization
if (foo.instance_of?(bar)) foo =foo.to_bar; 
istead foo=barconvert(foo);
So I did quick benchmark
require 'benchmark'
Benchmark.bm{|b|
b.report{1000000.times{|i|Fixnum;i.to_i}}
b.report{1000000.times{|i|i.instance_of?(Fixnum)}}
}
And first was bit better. 
I put Fixnum in first test because without took first test 0.6s and second 0.8s
So it makes your code slower.
Benchmark in C would show same.

In This Thread

Prev Next