in reply to Re^2: Module for transparently forking a sub?
in thread Module for transparently forking a sub?
So, you have time to make the claim, but not the time to substantiate it. There's a name for that:FUD!
Okay, here my counter claim.
I can start a thread, run a subroutine that returns a complex data structure, and retrieve that data structure to the calling code faster than you can do the same using fork. My timing is: 0.0261 seconds.
c:\test>junk8 -N=100 Time taken: 0.0261 seconds { A => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ARGS => [1, "2.3", "four"], B => { a => "b", c => "d", e => "f", g => "h", i => "j", k => "l", "m" => "n", o => "p", "q" => "r", "s" => "t", u => "v", w => "x", "y" => "z", }, C => "Just a big scalarJust a big scala big scalarJust a big scalarJust a big sc }
And my benchmark code:
#! perl -slw use strict; use threads; use Time::HiRes qw[ time ]; use Data::Dump qw[ pp ]; our $N ||= 10; sub stuff { my %hash = ( ARGS => \@_, A => [ 1 .. 10 ], B => { 'a' .. 'z' }, C => 'Just a big scalar' x 100, ); return \%hash; } my $complexData; my $start = time; for ( 1 .. $N ) { ## "fork" the subroutine my( $thread ) = async \&stuff, 1, 2.3, 'four' ; ## Do other stuff sleep 1; ## Get the complex results $complexData = $thread->join; } printf "Time taken: %.4f seconds\n", ( time() - $start ) / $N - 1; ## Display them pp $complexData;
Care to substantiate your claim and disprove mine?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Module for transparently forking a sub?
by samtregar (Abbot) on Feb 14, 2009 at 05:33 UTC | |
by BrowserUk (Patriarch) on Feb 14, 2009 at 20:08 UTC | |
by samtregar (Abbot) on Feb 14, 2009 at 20:54 UTC | |
by BrowserUk (Patriarch) on Feb 14, 2009 at 21:32 UTC | |
|
Re^4: Module for transparently forking a sub?
by samtregar (Abbot) on Feb 13, 2009 at 22:40 UTC | |
|
Re^4: Module for transparently forking a sub?
by Anonymous Monk on Feb 14, 2009 at 18:05 UTC |