[Vienna-pm] threaded Perl vs. plain Perl

Leopold Toetsch lt at toetsch.at
Fri Feb 13 10:56:00 CST 2004


Thomas Klausner wrote:

> Hi!
>   
> oha! mit threads ca 50% langsamer!

Ja. Kommt natürlich auf das Programm drauf an, im Zweifelsfall einfach 
testen.


> ... BZW wie/was sollte ein
> gutes Benchmark testen ?

That depends. Am Besten was aus der Praxis, was du verwendest.

BTW ich hab dein Programm mal nach PASM[1] übersetzt. Parrot ist von 
Haus aus multi-threaded. Allerdings gibt's keinen Penalty für Programme, 
die keine Threads nutzen. Hier die Ergebnisse auf meinem Athlon 800:

perl 5.8   19.5s
parrot -j  21.5s
parrot -C  22.1s
perl58-th  30.1s

Allerdings kennt Parrot noch kein join oder split, ich habe das jeweils 
in einer Schleife (in PASM) nachgebildet. Mit beiden Opcodes sollte es 
doch noch schneller gehen.

leo
[1] Parrot Assembler, aber eigentlich PIR eine mehr HLL-like Variante davon.

# beginn
#use strict;
#
#use warnings;

.sub _main

# my $big;
    .sym pmc big
    big = new PerlUndef
# my $string="just another perl hacker";
    .sym pmc String
    String = new PerlUndef
    String = "just another perl hacker"

# for (0 .. 299999) {
    $P0 = new PerlUndef
    $P0 = 0
loop:
#    $big++;
    inc big
#   my @str=split(//,$string);
    .sym pmc str
    str = new PerlArray
    $S0 = String
    length $I0, $S0
    $I1 = 0
  spl:
    $S1 = $S0[$I1]
    str[$I1] = $S1
    inc $I1
    if $I1 < $I0 goto spl
#    my $f=shift(@str);
    .sym pmc f
    f = new PerlUndef
    shift $P2, str
    assign f, $P2
#    push(@str,$f);
    push str, f
#    $string=join('', at str);
    String = new PerlString
    $I0 = str
    $I1 = 0
  jlp:
    $P1 = str[$I1]
    concat String, String, $P1
    inc $I1
    if $I1 < $I0 goto jlp
#}
   inc $P0
   if  $P0 <= 299999 goto loop

#print "$big;
    print big
    print "\n"
#$string
#";
    print String
    print "\n"
    end
# ende
.end





More information about the Vienna-pm mailing list