The short program, pushing '1' a thousand time on an array, takes about 25% more when threads are compiled in. Of course, YMMV.#!/usr/bin/perl use strict; use warnings; undef $/; my $code = <DATA>; my $RUNS = 10; my $no_threads = "/opt/perl/bin/perl-64"; my $threads = "/opt/perl/bin/thr-perl-64"; foreach my $perl ($no_threads, $threads) { my ($sum_r, $sum_u) = (0, 0); foreach my $runs (0 .. $RUNS) { my $res = `/usr/bin/time -p $perl -e '$code' 2>&1 `; next unless $runs; $sum_r += ($res =~ /real\s*(\d+\.\d+)/)[0]; $sum_u += ($res =~ /user\s*(\d+\.\d+)/)[0]; } printf "real: %.2f; user: %.2f\n", $sum_r / $RUNS, $sum_u / $RUNS; } __DATA__ use strict; use warnings; foreach (1 .. 1000) { my @arr; foreach (1 .. 1000) { push @arr, 1; } } __END__ real: 0.43; user: 0.43 real: 0.54; user: 0.54
In reply to Re^3: Approaches to concurrency
by JavaFan
in thread Approaches to concurrency
by tex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |