Thread Unerwartete Ergenisse mit Promise.start
(10 answers)
Opened by Kuerbis at 2015-09-02 12:52 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #!/usr/bin/env perl6 use v6; use Benchmark; my $n = 25_000; my $runs = 1; my $result; my @stats = timethis( $runs, sub { for ^$n { $result += $_ ** $_ } # ein Kern } ); say @stats; # 1441620270 1441620539 269 269 @stats = timethis( $runs, sub { my $sum = [+] await map { start { $_ ** $_ } }, ^$n; # benutzt alle 4 Kerne die "Error" if $sum != $result; } ); say @stats; # 1441620539 1441620618 79 79 |