■スレッドリストへ戻る■ 全部 1- 101- 201- 301- 401- 501- 601- 701- 801- 901- 1001- 最新50

【2ちゃんねるビューア】 巡回機能の巻。Part3

440 :名無しさん@お腹いっぱい。 :02/03/25 12:55 ID:???
Perlでなら、とりあえずsystem関数でgzip使うより、
Compress::Zlibモジュール使った方が速いみたい

Benchmark: timing 100 iterations of module, system...
  module: 6 wallclock secs ( 5.89 usr + 0.19 sys = 6.08 CPU)
  system: 10 wallclock secs ( 0.02 usr 0.06 sys + 8.43 cusr 1.32 csys = 0.00 CPU)
-----------------------------------------------------------
use strict;
use vars qw($file $i $j);
use Benchmark;
use Compress::Zlib;

BEGIN {
binmode(STDIN);
binmode(STDOUT);
$i = 0;# 出力ファイル名を変える必要はないけど
$j = 0;# 念のため

open(TEST, "testfile") or die;# 'testfile' ... 218KB
read(TEST, $file, -s TEST);
close(TEST);
}

timethese(100,{
'module' => q{
my $gz = gzopen("mod_$i.gz", "wb");
my $byteswritten = $gz->gzwrite($file);
$gz->gzclose();
++$i;
},
'system' => q{
system("gzip -c testfile > com_$j.gz");
++$j;
}
});

283KB
新着レスの表示

スレッドリストへ戻る 全部 前100 次100 最新50

0ch BBS 2004-10-30