File: gen_bench.pl

package info (click to toggle)
libdata-util-perl 0.67-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 556 kB
  • sloc: perl: 2,958; ansic: 416; makefile: 8
file content (38 lines) | stat: -rw-r--r-- 569 bytes parent folder | download | duplicates (5)
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
#!perl -w

use strict;
use Benchmark qw(:all);
use Data::Util qw(anon_scalar);

use FindBin qw($Bin);
use lib $Bin;
use Common;

signeture 'Data::Util' => \&anon_scalar;

cmpthese timethese -1 => {
	anon_scalar => sub{
		for(1 .. 10){
			my $ref = anon_scalar();
		}
	},
	'\do{my $tmp}' => sub{
		for(1 .. 10){
			my $ref = \do{ my $tmp };
		}
	},
};

print "\nwith an argument\n";
cmpthese timethese -1 => {
	anon_scalar => sub{
		for(1 .. 10){
			my $ref = anon_scalar(10);
		}
	},
	'\do{my $tmp}' => sub{
		for(1 .. 10){
			my $ref = \do{ my $tmp = 10 };
		}
	},
};