[Vienna-pm] threaded Perl vs. plain Perl
Thomas Klausner
domm at zsi.at
Fri Feb 13 10:17:13 CST 2004
Hi!
Wir erinnern uns: Vor einiger Zeit wollte ich auf Grund von Geruechten (Perl
mit threads ist langsamer als ohne) nicht das debian-Perl verwenden, sondern
mein eigenes, was mir danke Alfies Hilfe inzwischen auch gelungen ist.
Aber: Stimmt das Geruecht?
Ich hab grad perl-5.8.3 einmal mit, einmal ohne threads kompiliert (sonst
sind alle Config-settings gleich) und ein nicht sehr sinnvolles script
geschrieben, das halt unnoetig rumrechnet und string/array Zeugs macht:
# beginn
use strict;
use warnings;
my $big;
my $string="just another perl hacker";
for (0 .. 299999) {
$big++;
my @str=split(//,$string);
my $f=shift(@str);
push(@str,$f);
$string=join('', at str);
}
print "$big;
$string
";
# ende
(Das ganze ist absichtlich ineffizient geschrieben...)
so, dann hab ich time angeworfen, mit folgendem Ergebnis:
ohne threads:
~/perl/benchmark$ time plain_perl/bin/perl test.pl
300000;
just another perl hacker
real 0m9.906s
user 0m9.870s
sys 0m0.030s
mit threads:
~/perl/benchmark$ time thread_perl/bin/perl test.pl
300000;
just another perl hacker
real 0m15.078s
user 0m15.000s
sys 0m0.080s
oha! mit threads ca 50% langsamer!
Mein Benchmark-script ist natuerlich volkommener Bloedsinn und testet
viel zu wenig. Hat da jemand was ausfuehrlicheres? BZW wie/was sollte ein
gutes Benchmark testen ?
--
#!/usr/bin/perl http://domm.zsi.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}
More information about the Vienna-pm
mailing list