Skip to content

Instantly share code, notes, and snippets.

@kfly8
Last active June 17, 2019 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kfly8/f28b02005c2bda44aaa4d8994dfdcc16 to your computer and use it in GitHub Desktop.
Save kfly8/f28b02005c2bda44aaa4d8994dfdcc16 to your computer and use it in GitHub Desktop.
benchmark
# 360653.77/s F::P and F::R and F::I
# 1499189.22/s F::P and F::R no_check and F::I
# 1499189.22/s F::P and F::R no_check
# 1499189.22/s F::P
package Hello;
use Types::Standard -types;
use Function::Parameters;
fun message(Str $msg) {
return "HELLO $msg";
}
1;
package Hello;
use Function::Interface::Impl qw(
HelloInterface
);
use Types::Standard -types;
fun message(Str $msg) :Return(Str) {
return "HELLO $msg";
}
1;
package Hello;
use Types::Standard -types;
use Function::Return no_check => 1;
use Function::Parameters;
fun message(Str $msg) :Return(Str) {
return "HELLO $msg";
}
1;
package Hello;
use Function::Interface::Impl qw(
HelloInterface
);
use Types::Standard -types;
use Function::Return no_check => 1;
fun message(Str $msg) :Return(Str) {
return "HELLO $msg";
}
1;
use strictures 2;
use Benchmark qw(cmpthese);
package Case1 {
use Function::Interface::Impl qw(HelloInterface);
use Types::Standard -types;
fun hello(Str $msg) :Return(Str) {
return "HELLO $msg";
}
}
package Case2 {
use Function::Interface::Impl qw(HelloInterface);
use Types::Standard -types;
use Function::Return no_check => 1;
fun hello(Str $msg) :Return(Str) {
return "HELLO $msg";
}
}
package Case3 {
use Types::Standard -types;
use Function::Return no_check => 1;
use Function::Parameters;
fun hello(Str $msg) :Return(Str) {
return "HELLO $msg";
}
}
package Case4 {
use Types::Standard -types;
use Function::Parameters;
fun hello(Str $msg) {
return "HELLO $msg";
}
}
cmpthese -1, {
'F::P and F::R and F::I' => sub { Case1::hello("Pittsburgh") },
'F::P and F::R no_check and F::I' => sub { Case2::hello("Pittsburgh") },
'F::P and F::R no_check' => sub { Case3::hello("Pittsburgh") },
'F::P' => sub { Case4::hello("Pittsburgh") },
};
# Rate F::P and F::R and F::I F::P and F::R no_check and F::I F::P and F::R no_check F::P
# F::P and F::R and F::I 389212/s -- -77% -78% -78%
# F::P and F::R no_check and F::I 1683493/s 333% -- -3% -3%
# F::P and F::R no_check 1731140/s 345% 3% -- -0%
# F::P 1739003/s 347% 3% 0% --
#
# Rate F::P and F::R and F::I F::P and F::R no_check F::P F::P and F::R no_check and F::I
# F::P and F::R and F::I 392991/s -- -76% -77% -77%
# F::P and F::R no_check 1654154/s 321% -- -3% -3%
# F::P 1699081/s 332% 3% -- -0%
# F::P and F::R no_check and F::I 1699081/s 332% 3% 0% --
#
# Rate F::P and F::R and F::I F::P and F::R no_check and F::I F::P F::P and F::R no_check
# F::P and F::R and F::I 389212/s -- -77% -77% -78%
# F::P and F::R no_check and F::I 1686587/s 333% -- -2% -3%
# F::P 1714960/s 341% 2% -- -2%
# F::P and F::R no_check 1747627/s 349% 4% 2% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment