in reply to Re^3: Benchmarking "Are all these characters in this sentence?" (quickest yet?)
in thread Benchmarking "Are all these characters in this sentence?"

I was just updating my other reply to that effect, that's it.

$_ is a bit scary sometimes, it's auto-scoped so often that it's hard to remember it isn't alway so...


Mike
  • Comment on Re^4: Benchmarking "Are all these characters in this sentence?" (quickest yet?)

Replies are listed 'Best First'.
Re^5: Benchmarking "Are all these characters in this sentence?" (quickest yet?)
by BrowserUk (Patriarch) on Aug 30, 2008 at 21:51 UTC

    Of course, we then apply the so called "micro optimisations" to that:

    buk2 => sub { local $_; 1+index $_[0], $_ or return while $_ = chop $_[1]; 1; },

    Though the results of doing so can harldy be called "micro" when they result in an order of magnitude speed up over the non-optimised equivalent; 15 times faster than the next best; and 60 times faster than the original!

    c:\test>707621.pl Running benchmarks... Short Rate unpack_allindex unpack_allrindex repellent_unp +ack tye2 tye1 tye0 buk buk2 unpack_allindex 212/s -- -0% - +42% -56% -56% -66% -77% -92% unpack_allrindex 212/s 0% -- - +42% -56% -56% -65% -77% -92% repellent_unpack 365/s 73% 72% + -- -24% -25% -41% -61% -86% tye2 481/s 127% 126% +32% -- -1% -22% -48% -82% tye1 484/s 129% 128% +32% 1% -- -21% -48% -81% tye0 614/s 190% 189% +68% 28% 27% -- -34% -76% buk 930/s 340% 338% 1 +55% 93% 92% 51% -- -64% buk2 2606/s 1132% 1127% 6 +14% 442% 439% 324% 180% -- LongShort Rate unpack_allrindex unpack_allindex repellent_unp +ack tye2 tye1 tye0 buk buk2 unpack_allrindex 271/s -- -1% - +50% -60% -63% -74% -79% -94% unpack_allindex 274/s 1% -- - +49% -60% -63% -73% -79% -94% repellent_unpack 537/s 98% 96% + -- -22% -27% -48% -59% -88% tye2 684/s 152% 150% +27% -- -7% -33% -48% -85% tye1 735/s 171% 169% +37% 7% -- -28% -44% -84% tye0 1027/s 279% 275% +91% 50% 40% -- -21% -77% buk 1306/s 382% 377% 1 +43% 91% 78% 27% -- -71% buk2 4508/s 1563% 1547% 7 +40% 559% 513% 339% 245% -- ShortLong Rate unpack_allrindex unpack_allindex repellent_unp +ack tye0 tye2 tye1 buk buk2 unpack_allrindex 5.41/s -- -2% +-8% -71% -73% -73% -85% -99% unpack_allindex 5.49/s 2% -- +-7% -70% -73% -73% -85% -99% repellent_unpack 5.91/s 9% 8% + -- -68% -71% -71% -84% -99% tye0 18.4/s 241% 236% 2 +12% -- -8% -8% -49% -97% tye2 20.1/s 271% 265% 2 +40% 9% -- -0% -45% -97% tye1 20.1/s 272% 267% 2 +41% 9% 0% -- -45% -97% buk 36.3/s 571% 561% 5 +15% 97% 81% 80% -- -94% buk2 607/s 11128% 10956% 101 +77% 3193% 2926% 2915% 1572% -- LongLong Rate repellent_unpack unpack_allrindex unpack_allin +dex tye0 tye2 tye1 buk buk2 repellent_unpack 5.41/s -- -3% +-6% -70% -73% -73% -85% -99% unpack_allrindex 5.56/s 3% -- +-3% -69% -72% -72% -85% -99% unpack_allindex 5.73/s 6% 3% + -- -68% -71% -71% -84% -99% tye0 18.1/s 235% 226% 2 +17% -- -8% -9% -50% -97% tye2 19.8/s 266% 256% 2 +46% 9% -- -1% -45% -96% tye1 20.0/s 270% 260% 2 +49% 10% 1% -- -45% -96% buk 36.3/s 571% 553% 5 +33% 100% 83% 81% -- -93% buk2 545/s 9980% 9708% 94 +17% 2905% 2652% 2627% 1403% -- VeryLong Rate unpack_allrindex unpack_allindex repellent_un +pack tye2 tye1 tye0 buk buk2 unpack_allrindex 403/s -- -8% +-42% -55% -55% -56% -73% -97% unpack_allindex 439/s 9% -- +-37% -51% -51% -52% -71% -97% repellent_unpack 694/s 72% 58% + -- -23% -23% -24% -54% -95% tye2 897/s 123% 104% + 29% -- -0% -2% -40% -93% tye1 897/s 123% 104% + 29% 0% -- -2% -40% -93% tye0 917/s 128% 109% + 32% 2% 2% -- -39% -93% buk 1493/s 271% 240% +115% 67% 67% 63% -- -89% buk2 13013/s 3132% 2863% 1 +774% 1351% 1351% 1319% 771% --

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^5: Benchmarking "Are all these characters in this sentence?" (quickest yet?)
by BrowserUk (Patriarch) on Aug 30, 2008 at 21:51 UTC

    Of course, we can then apply the so called "micro optimisations" to that:

    buk2 => sub { local $_; 1+index $_[0], $_ or return while $_ = chop $_[1]; 1; },

    Though the results of doing so can hardly be called "micro" when they result in an order of magnitude speed up over the non-optimised equivalent; 15 times faster than the next best; and 60 times faster than the original!

    c:\test>707621.pl Running benchmarks... Short Rate tallulah_OriginalPost unpack_allrindex un +pack_allindex repellent_unpack tye2 tye1 tye0 buk buk2 tallulah_OriginalPost 41.4/s -- -80% + -80% -89% -92% -92% -93% -96% -98% unpack_allrindex 206/s 396% -- + -3% -47% -59% -59% -67% -80% -92% unpack_allindex 212/s 413% 3% + -- -46% -57% -57% -65% -80% -92% repellent_unpack 391/s 844% 90% + 84% -- -21% -21% -36% -63% -85% tye2 498/s 1102% 142% + 134% 27% -- -0% -19% -53% -80% tye1 498/s 1102% 142% + 134% 27% 0% -- -19% -53% -80% tye0 614/s 1382% 199% + 189% 57% 23% 23% -- -42% -76% buk 1052/s 2439% 411% + 395% 169% 111% 111% 71% -- -58% buk2 2529/s 6004% 1129% + 1090% 546% 408% 408% 312% 140% -- LongShort Rate tallulah_OriginalPost unpack_allrindex un +pack_allindex repellent_unpack tye1 tye2 tye0 buk buk2 tallulah_OriginalPost 64.0/s -- -75% + -75% -88% -91% -91% -94% -96% -99% unpack_allrindex 258/s 303% -- + -0% -52% -63% -63% -75% -82% -95% unpack_allindex 259/s 305% 0% + -- -52% -63% -63% -75% -82% -95% repellent_unpack 540/s 744% 109% + 108% -- -22% -23% -48% -63% -89% tye1 694/s 985% 169% + 168% 29% -- -1% -33% -52% -85% tye2 703/s 998% 172% + 171% 30% 1% -- -33% -51% -85% tye0 1043/s 1529% 304% + 302% 93% 50% 48% -- -28% -78% buk 1449/s 2164% 462% + 459% 168% 109% 106% 39% -- -69% buk2 4740/s 7307% 1737% + 1728% 778% 583% 574% 355% 227% -- ShortLong (warning: too few iterations for a reliable count) Rate tallulah_OriginalPost repellent_unpack un +pack_allindex unpack_allrindex tye0 tye1 tye2 buk buk2 tallulah_OriginalPost 1.01/s -- -82% + -82% -83% -95% -95% -95% -97% -100% repellent_unpack 5.57/s 452% -- + -3% -6% -71% -72% -72% -86% -99% unpack_allindex 5.73/s 468% 3% + -- -3% -70% -71% -71% -86% -99% unpack_allrindex 5.91/s 486% 6% + 3% -- -69% -70% -70% -85% -99% tye0 19.1/s 1794% 243% + 233% 223% -- -4% -4% -53% -97% tye1 19.8/s 1865% 256% + 246% 235% 4% -- -1% -51% -97% tye2 20.0/s 1878% 258% + 248% 237% 4% 1% -- -50% -97% buk 40.2/s 3888% 623% + 602% 580% 111% 103% 102% -- -93% buk2 607/s 60074% 10804% + 10490% 10167% 3077% 2962% 2942% 1409% -- LongLong (warning: too few iterations for a reliable count) Rate tallulah_OriginalPost repellent_unpack un +pack_allindex unpack_allrindex tye0 tye2 tye1 buk buk2 tallulah_OriginalPost 1.07/s -- -81% + -81% -81% -94% -94% -95% -97% -100% repellent_unpack 5.49/s 415% -- + -3% -4% -71% -72% -72% -86% -99% unpack_allindex 5.65/s 430% 3% + -- -1% -70% -71% -71% -86% -99% unpack_allrindex 5.73/s 437% 4% + 1% -- -70% -70% -71% -86% -99% tye0 19.0/s 1681% 246% + 236% 232% -- -1% -3% -53% -97% tye2 19.3/s 1708% 251% + 241% 237% 1% -- -2% -52% -97% tye1 19.7/s 1745% 259% + 248% 244% 4% 2% -- -51% -97% buk 40.4/s 3687% 636% + 615% 606% 113% 109% 105% -- -93% buk2 592/s 55368% 10678% + 10372% 10234% 3014% 2969% 2906% 1365% -- VeryLong Rate tallulah_OriginalPost unpack_allrindex u +npack_allindex repellent_unpack tye1 tye2 tye0 buk buk2 tallulah_OriginalPost 70.5/s -- -85% + -85% -90% -91% -92% -92% -96% -99% unpack_allrindex 469/s 565% -- + -0% -33% -42% -48% -49% -71% -96% unpack_allindex 470/s 567% 0% + -- -32% -42% -48% -49% -71% -96% repellent_unpack 696/s 888% 48% + 48% -- -14% -22% -25% -57% -95% tye1 813/s 1053% 73% + 73% 17% -- -9% -12% -49% -94% tye2 897/s 1173% 91% + 91% 29% 10% -- -3% -44% -93% tye0 923/s 1210% 97% + 96% 33% 14% 3% -- -42% -93% buk 1604/s 2176% 242% + 241% 130% 97% 79% 74% -- -87% buk2 12775/s 18020% 2624% + 2616% 1734% 1471% 1324% 1283% 696% --

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.