File: bench_return.pl

package info (click to toggle)
libmoosex-has-sugar-perl 1.000006-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 408 kB
  • sloc: perl: 629; sh: 7; makefile: 2
file content (75 lines) | stat: -rw-r--r-- 1,907 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env perl
# FILENAME: bench_return.pl
# CREATED: 06/26/14 07:41:05 by Kent Fredric (kentnl) <kentfredric@gmail.com>
# ABSTRACT: Benchmark difference of return styles

use strict;
use warnings;
use utf8;

sub constant_return() {
  return ( 'is', 'ro' );
}

sub constant_bare() {
  ( 'is', 'ro' );
}

use Benchmark qw( :all :hireswallclock );

cmpthese(
  -2,
  {
    return => sub {
      my @x;
      @x = constant_return for 0 .. 100;
    },
    bare => sub {
      my @x;
      @x = constant_bare for 0 .. 100;
    },
    return2 => sub {
      my @x;
      @x = constant_return for 0 .. 100;
    },
    bare2 => sub {
      my @x;
      @x = constant_bare for 0 .. 100;
    },
  }
);

__END__
5.21.1
config_args='-de -Dusecbacktrace -Doptimize=-O3 -march=native -mtune=native -g -ggdb3 -Dusedevel -Accflags=-DUSE_C_BACKTRACE_ON_ERROR -Aldflags=-lbfd

           Rate    bare   bare2 return2  return
bare2   16364/s      --     -1%     -6%     -6%
bare    16527/s      1%      --     -5%     -5%
return2 17436/s      7%      6%      --     -0%
return  17436/s      7%      6%      0%      --

5.10.1
config_args='-de'

           Rate    bare   bare2 return2  return
bare    12155/s      --     -0%     -1%     -1%
bare2   12190/s      0%      --     -1%     -1%
return2 12272/s      1%      1%      --     -0%
return  12272/s      1%      1%      0%      --

5.18.0
config_args='-de'
             Rate    bare   bare2  return return2
bare2   12597/s      --     -1%     -4%     -4%
bare    12664/s      1%      --     -4%     -4%
return2 13149/s      4%      4%      --     -0%
return  13149/s      4%      4%      0%      --

5.12.5
config_args='-de'
             Rate    bare   bare2 return2  return
bare    10803/s      --     -3%     -7%     -7%
bare2   11112/s      3%      --     -4%     -4%
return  11555/s      7%      4%      --     -0%
return2 11600/s      7%      4%      0%      --