[Chicago-talk] Removing "." from a string?
lembark at wrkhors.com
Fri Feb 1 15:28:08 PST 2008
Eric Ellington wrote:
>> subst: 0 wallclock secs ( 0.91 usr + 0.00 sys = 0.91 CPU) @
>> 10989010.99/s (n=10000000)
>> tr: 1 wallclock secs ( 1.51 usr + 0.00 sys = 1.51 CPU) @
>> 6622516.56/s (n=10000000)
>> 'subst' => "\$dotted_quad =~ s/\D//g;",
> I am confused. Didn't Andy Bach show that s/// was the quickest in this case?
> In what case would tr be quicker?
No index + substr is. Index is a single C call
and substr does a single memcpy within the
malloc'd block and reduces the string length.
Steven Lembark +1 888 359 3508
Workhorse Computing 85-09 90th St
lembark at wrkhors.com Woodhaven, NY 11421
More information about the Chicago-talk