Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Weird performance issue with Strawberries and Inline::C

by Anonymous Monk
on Oct 16, 2025 at 08:32 UTC ( [id://11166525]=note: print w/replies, xml ) Need Help??


in reply to Weird performance issue with Strawberries and Inline::C

How about this:

use strict; use warnings; use feature 'say'; use Benchmark 'cmpthese'; use constant L => 1e5; my @cases; my $str = '1' x L; push @cases, $str; substr $str, rand L, 1 , '0' for 1 .. L; push @cases, $str; push @cases, '01' x ( L / 2 ); say $^V; for my $s ( @cases ) { cmpthese -2, { count => sub { $s =~ tr/1// }, } } __END__ v5.32.1 Rate count count 21711/s -- Rate count count 21607/s -- Rate count count 21348/s -- v5.42.0 Rate count count 16271/s -- Rate count count 2422/s -- Rate count count 8136/s --

String composition affects as trivial operation as counting. Looks like someone not heeded the advice to "write like C3, not C4" and relied on compiler voodoo, when writing Perl itself, not silly solution for PWC. Though of course it may be something else rather than innocent "if" with its jumps. Maybe situation can't be shrugged off after all.

Replies are listed 'Best First'.
Re^2: Weird performance issue with Strawberries and Inline::C
by ikegami (Patriarch) on Oct 16, 2025 at 15:00 UTC

    What's with the rand? Your results are meaningless. The results from the different versions can't be compared to each other, and the results from one version can't be compared to each other. Finally, none of your test cases uses OOK scalars, and the whole question is about OOK scalars.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11166525]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2026-01-16 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (118 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.