[表示 : 全て 最新50 1-99 101- 201- 301- 401- 501- 2chのread.cgiへ]
Update time : 05/09 10:44 / Filesize : 117 KB / Number-of Response : 547
[このスレッドの書き込みを削除する]
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧] [類似スレッド一覧]


↑キャッシュ検索、類似スレ動作を修正しました、ご迷惑をお掛けしました

【えっ】Perlに未来はあるのか?【終わり?】



121 名前:デフォルトの名無しさん mailto:sage [2007/07/31(火) 04:11:27 ]
>>118
そのコードで何を計測しているつもりなんだ?

#!/usr/bin/perl -w
use strict;
use Benchmark qw(timethese);

my $i = 0;
my $str = join '', 'a'..'m';
my @line;
push(@line, $str), substr($str, 0, 0, chop $str) for 1..1000;

timethese(-5, {
  re1 => sub { /^(?=(?:abcdef|ghijklm))/ and ++$i for @line },
  re2 => sub { /^(?=abcdef)/ || /^(?=ghijklm)/ and ++$i for @line },
  re3 => sub { /^abcdef/ || /^ghijklm/ and ++$i for @line },
  idx => sub { index($_, 'abcdef', 0) == 0 || index($_, 'ghijklm', 0) == 0 and ++$i for @line },
});

@line = ();
push @line, join '', map +('a','b')[ rand 2 ], 1..10 for 1..1000;

timethese(-5, {
  re1 => sub { /^(?=ab..)(?=..ab)/ and ++$i for @line },
  re2 => sub { /^(?=ab..)/ && /^(?=..ab)/ and ++$i for @line },
  re3 => sub { /^ab../ && /^..ab/ and ++$i for @line },
  idx => sub { index($_, 'ab', 0) == 0 && index($_, 'ab', 2) == 2 and ++$i for @line },
});






[ 続きを読む ] / [ 携帯版 ]

全部読む 前100 次100 最新50 [ このスレをブックマーク! 携帯に送る ] 2chのread.cgiへ
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧]( ´∀`)<117KB

read.cgi ver5.27 [feat.BBS2 +1.6] / e.0.2 (02/09/03) / eucaly.net products.
担当:undef