Last active
August 29, 2015 14:20
-
-
Save bayashi/6c243af7377820909f36 to your computer and use it in GitHub Desktop.
benchmark of building place holder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Benchmarks sub { | |
my @list = (1..10); | |
+{ | |
map_join => sub { | |
join(',', map { '?' } @list); | |
}, | |
x_join => sub { | |
join(',', ('?') x scalar(@list)); | |
}, | |
x => sub { | |
'?,' x (scalar(@list) - 1). '?'; | |
}, | |
}; | |
}; | |
=pod | |
1..10 | |
Benchmark: running map_join, x, x_join for at least 1 CPU seconds... | |
map_join: 1.04042 wallclock secs ( 1.04 usr + 0.00 sys = 1.04 CPU) @ 220552.88/s (n=229375) | |
x: 1.05466 wallclock secs ( 1.05 usr + 0.00 sys = 1.05 CPU) @ 1638399.05/s (n=1720319) | |
x_join: 1.03598 wallclock secs ( 1.03 usr + 0.00 sys = 1.03 CPU) @ 477202.91/s (n=491519) | |
Rate map_join x_join x | |
map_join 220553/s -- -54% -87% | |
x_join 477203/s 116% -- -71% | |
x 1638399/s 643% 243% -- | |
1..100 | |
Benchmark: running map_join, x, x_join for at least 1 CPU seconds... | |
map_join: 1.05057 wallclock secs ( 1.05 usr + 0.00 sys = 1.05 CPU) @ 21557.14/s (n=22635) | |
x: 1.05918 wallclock secs ( 1.06 usr + 0.00 sys = 1.06 CPU) @ 865569.81/s (n=917504) | |
x_join: 1.07109 wallclock secs ( 1.07 usr + 0.00 sys = 1.07 CPU) @ 53591.59/s (n=57343) | |
Rate map_join x_join x | |
map_join 21557/s -- -60% -98% | |
x_join 53592/s 149% -- -94% | |
x 865570/s 3915% 1515% -- | |
1..1000 | |
Benchmark: running map_join, x, x_join for at least 1 CPU seconds... | |
map_join: 1.11826 wallclock secs ( 1.11 usr + 0.00 sys = 1.11 CPU) @ 2200.90/s (n=2443) | |
x: 1.04846 wallclock secs ( 1.05 usr + 0.00 sys = 1.05 CPU) @ 148944.76/s (n=156392) | |
x_join: 1.09108 wallclock secs ( 1.09 usr + 0.00 sys = 1.09 CPU) @ 5479.82/s (n=5973) | |
Rate map_join x_join x | |
map_join 2201/s -- -60% -99% | |
x_join 5480/s 149% -- -96% | |
x 148945/s 6667% 2618% -- | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment