use strict; use warnings; use PDL; use Storable 'dclone'; use Benchmark 'cmpthese'; for my $size ( 4 .. 8 ) { print "*** string size is 1E$size bytes\n"; my $data = byte( 256 * random( 10 ** $size )); my $buf = $data-> get_dataref; cmpthese( -2, { copy => sub { $data-> copy-> get_dataref }, dclone => sub { dclone $buf }, concat => sub { \( ${ $buf } . '' )}, }); print "\n"; } __END__ Perl executable: C:\berrybrew\strawberry-perl-5.32.0.1-64bit-PDL\perl\bin\perl.exe Perl version : 5.32.0 / MSWin32-x64-multi-thread PDL version : 2.021 *** string size is 1E4 bytes Rate copy dclone concat copy 56875/s -- -72% -95% dclone 201992/s 255% -- -83% concat 1182933/s 1980% 486% -- *** string size is 1E5 bytes Rate copy dclone concat copy 7703/s -- -90% -94% dclone 76109/s 888% -- -43% concat 134245/s 1643% 76% -- *** string size is 1E6 bytes Rate copy dclone concat copy 808/s -- -82% -83% dclone 4538/s 462% -- -4% concat 4713/s 484% 4% -- *** string size is 1E7 bytes Rate copy concat dclone copy 67.8/s -- -70% -71% concat 228/s 236% -- -1% dclone 230/s 240% 1% -- *** string size is 1E8 bytes Rate copy dclone concat copy 6.84/s -- -69% -69% dclone 21.8/s 219% -- -1% concat 22.1/s 223% 1% --