Sorting algorithms/Merge sort: Difference between revisions

imported>Rcmlz
imported>Rcmlz
Line 6,546:
}
</syntaxhighlight>
 
and tune the parallel hyper-parameter - as creating a (potentially) huge number of new threads by the naive parallel approach is contra productive.
 
<syntaxhighlight lang="raku" line>
constant $BATCH-SIZE = 2**10;
my atomicint $worker = $*KERNEL.cpu-cores;
Line 6,594 ⟶ 6,596:
take @left-sorted, @right-sorted;
}
}
}</syntaxhighlight>
 
And finaly some tests and benchmarking ( on my Laptop from 2013 )
 
<syntaxhighlight lang="raku" line>
use Test;
Line 6,662 ⟶ 6,667:
mergesort => avg: 5.2 secs, total 52 secs
mergesort-parallel => avg: 2.3 secs, total 23 secs
mergesort-parallel-naive => avg: 6.2 secs, total 62 secs</pre>
</pre>
 
=={{header|REBOL}}==
Anonymous user