## Test code to show split slow when used in muiltiple threads is slow in cygwin perl use strict; use warnings; use threads; use Thread::Queue; use Time::HiRes(); my $string = "12356789 "x25; my $TASK_COUNT =10; print( (`$^X -v`)[1]); thread_process(1); thread_process(4); sub thread_process { my $parallel = shift; my $start = Time::HiRes::time(); my @threads; my $queue = Thread::Queue->new(); for my $p ( 1 .. $parallel ) { push @threads, threads->create( sub { while( my $task_no = $queue->dequeue) { for my $n (1..10_000) { my @x= split / /, $string; # Split } }}) } $queue->enqueue( 1 .. $TASK_COUNT , (undef) x $parallel ); $_->join for @threads; my $end= Time::HiRes::time(); printf "Processing %d tasks in %d threads completed in %fsecs\n", $TASK_COUNT, $parallel, $end-$start; } __END__ # Here is an example of the output on my dual core XP machine $ ~/localperl/bin/perl.exe example.split.pl This is perl 5, version 14, subversion 1 (v5.14.1) built for cygwin-thread-multi-64int Processing 10 tasks in 1 threads completed in 2.640625secs Processing 10 tasks in 4 threads completed in 12.468637secs $ perl example.split.pl This is perl, v5.10.0 built for cygwin-thread-multi-64int Processing 10 tasks in 1 threads completed in 4.578125secs Processing 10 tasks in 4 threads completed in 25.437345secs # The defect does not occur with ActivePerl. Instead the expected slightly faster result occurs $ c:/perl/bin/perl example.split.pl This is perl 5, version 12, subversion 3 (v5.12.3) built for MSWin32-x86-multi-thread Processing 10 tasks in 1 threads completed in 2.062500secs Processing 10 tasks in 4 threads completed in 1.671790secs