in reply to Did the inefficiency of /i get fixed?
produces:#!/usr/bin/perl -w use strict; use Benchmark; our $s = "A" x 1024; timethese(1_000_000, { 'slash i' => sub { $s =~ /a/i; $s =~ /b/i; }, 'brackets' => sub { $s =~ /[Aa]/; $s =~ /[Bb]/; }, });
Benchmark: timing 1000000 iterations of brackets, slash i... brackets: 24 wallclock secs (24.20 usr + 0.00 sys = 24.20 CPU) @ 41322.31/s (n=1000000) slash i: 14 wallclock secs (13.47 usr + 0.00 sys = 13.47 CPU) @ 74239.05/s (n=1000000)
|
|---|