本帖最后由 523066680 于 2019-3-21 19:28 编辑
- use Time::HiRes qw/time/;
- STDOUT->autoflush(1);
- my $ta = time();
- my @upper = ('A'..'Z');
- my @eles = ('a'..'z', 'A'..'Z', '0'..'9');
- my $e_len = scalar(@eles);
- my $key;
- for my $i (1..1000000)
- {
- $key = $upper[rand(26)] . join("", map { $eles[rand($e_len)] } (1..6) ) ;
- printf "%s\n", $key;
- }
- printf STDERR "time usage %.2f", time()-$ta;
复制代码 genCode.pl >F:/temp/a.txt
输出到机械硬盘,100W个,4秒
join "", map {} () 改成末尾append形式,100W个,3秒- for my $i (1..1000000)
- {
- $key = $upper[rand(26)];
- grep { $key .= $eles[rand($e_len)] } (1..6);
- printf "%s\n", $key;
- }
复制代码 CPU 频率 4GHz |