Linux cpanel2.daytoncreative.net 2.6.32-754.29.2.el6.x86_64 #1 SMP Tue May 12 17:39:04 UTC 2020 x86_64
Apache/2.4.43 (cPanel) OpenSSL/1.1.1g mod_bwlimited/1.4
Server IP : 70.62.220.67 & Your IP : 216.73.216.193
Domains :
Cant Read [ /etc/named.conf ]
User : michaelgreg
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
log /
perl-5.20.2 /
lib /
Delete
Unzip
Name
Size
Permission
Date
Action
App
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Archive
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
Attribute
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
B
[ DIR ]
drwxr-xr-x
2016-10-10 17:38
CGI
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
CPAN
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
Carp
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
Class
[ DIR ]
drwxr-xr-x
2015-02-14 16:56
Compress
[ DIR ]
drwxr-xr-x
2016-10-10 17:38
Config
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
DBM_Filter
[ DIR ]
drwxr-xr-x
2015-02-14 16:56
Data
[ DIR ]
drwxr-xr-x
2016-10-10 17:38
Devel
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
Digest
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
Encode
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
Exporter
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
ExtUtils
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
File
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
Filter
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
Getopt
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
HTTP
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
Hash
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
I18N
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
IO
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
IPC
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
JSON
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
List
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
Locale
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
MIME
[ DIR ]
drwxr-xr-x
2016-10-10 17:40
Math
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Memoize
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Module
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Net
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Package
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Params
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Parse
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Perl
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
PerlIO
[ DIR ]
drwxr-xr-x
2016-10-10 17:40
Pod
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Scalar
[ DIR ]
drwxr-xr-x
2016-10-10 17:39
Search
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Sys
[ DIR ]
drwxr-xr-x
2016-10-10 17:40
TAP
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Term
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Test
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Text
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Thread
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
Tie
[ DIR ]
drwxr-xr-x
2016-10-10 17:40
Time
[ DIR ]
drwxr-xr-x
2016-10-10 17:40
Unicode
[ DIR ]
drwxr-xr-x
2016-10-10 17:40
User
[ DIR ]
drwxr-xr-x
2015-02-14 16:56
XS
[ DIR ]
drwxr-xr-x
2016-10-10 17:41
auto
[ DIR ]
drwxr-xr-x
2016-10-10 18:16
autodie
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
encoding
[ DIR ]
drwxr-xr-x
2016-10-10 17:36
feature
[ DIR ]
drwxr-xr-x
2015-02-14 16:56
inc
[ DIR ]
drwxr-xr-x
2016-10-10 17:37
overload
[ DIR ]
drwxr-xr-x
2016-10-10 18:13
perl5db
[ DIR ]
drwxr-xr-x
2015-02-14 16:56
threads
[ DIR ]
drwxr-xr-x
2016-10-10 17:40
unicore
[ DIR ]
drwxr-xr-x
2016-10-10 18:53
version
[ DIR ]
drwxr-xr-x
2016-10-10 17:38
warnings
[ DIR ]
drwxr-xr-x
2015-02-14 16:56
.exists
0
B
-rw-r--r--
2016-10-10 18:16
AnyDBM_File.pm
2.56
KB
-r--r--r--
2014-12-27 11:48
AnyDBM_File.t
3.36
KB
-r--r--r--
2014-12-27 11:48
AutoLoader.pm
15.43
KB
-r--r--r--
2014-12-27 11:48
AutoSplit.pm
19.18
KB
-r--r--r--
2014-12-27 11:48
B.pm
28.07
KB
-r--r--r--
2014-12-27 11:49
Benchmark.pm
29.22
KB
-r--r--r--
2014-12-27 11:49
Benchmark.t
21.04
KB
-r--r--r--
2014-12-27 11:48
CGI.pm
255.23
KB
-r--r--r--
2014-12-27 11:49
CORE.pod
3.19
KB
-r--r--r--
2014-12-27 11:48
CPAN.pm
134.45
KB
-r--r--r--
2014-12-27 11:48
Carp.pm
27.8
KB
-r--r--r--
2014-12-27 11:49
Config.pm
3.18
KB
-rw-r--r--
2016-10-10 17:36
Config.pod
229.34
KB
-rw-r--r--
2016-10-10 17:36
Config.t
8.26
KB
-r--r--r--
2014-12-27 11:48
Config_git.pl
409
B
-rw-r--r--
2016-10-10 17:36
Config_heavy.pl
40.41
KB
-rw-r--r--
2016-10-10 17:36
Cwd.pm
21.95
KB
-r--r--r--
2015-01-10 12:06
DB.pm
18.5
KB
-r--r--r--
2014-12-27 11:48
DB.t
16.28
KB
-r--r--r--
2014-12-27 11:48
DBM_Filter.pm
14.05
KB
-r--r--r--
2014-12-27 11:48
DB_File.pm
62.24
KB
-r--r--r--
2016-10-10 17:38
Digest.pm
10.35
KB
-r--r--r--
2014-12-27 11:48
DirHandle.pm
1.52
KB
-r--r--r--
2014-12-27 11:48
DirHandle.t
930
B
-r--r--r--
2014-12-27 11:48
Dumpvalue.pm
16.5
KB
-r--r--r--
2014-12-27 11:48
DynaLoader.pm
24.99
KB
-r--r--r--
2016-10-10 17:38
Encode.pm
32.44
KB
-r--r--r--
2014-12-27 11:49
English.pm
4.64
KB
-r--r--r--
2014-12-27 11:48
English.t
4.11
KB
-r--r--r--
2014-12-27 11:48
Env.pm
5.39
KB
-r--r--r--
2014-12-27 11:48
Errno.pm
6.33
KB
-r--r--r--
2016-10-10 17:36
Exporter.pm
18.31
KB
-r--r--r--
2014-12-27 11:49
Fatal.pm
59.38
KB
-r--r--r--
2014-12-27 11:49
Fcntl.pm
3.83
KB
-r--r--r--
2014-12-27 11:49
FileCache.pm
5.44
KB
-r--r--r--
2014-12-27 11:48
FileHandle.pm
6.62
KB
-r--r--r--
2014-12-27 11:48
FileHandle.t
2.48
KB
-r--r--r--
2014-12-27 11:48
FindBin.pm
4.45
KB
-r--r--r--
2014-12-27 11:48
FindBin.t
338
B
-r--r--r--
2014-12-27 11:48
GDBM_File.pm
1.51
KB
-r--r--r--
2014-12-27 11:48
IO.pm
1.36
KB
-r--r--r--
2014-12-27 11:49
Internals.t
5.04
KB
-r--r--r--
2014-12-27 11:48
Memoize.pm
35.28
KB
-r--r--r--
2014-12-27 11:48
NDBM_File.pm
2.44
KB
-r--r--r--
2014-12-27 11:49
NEXT.pm
18.05
KB
-r--r--r--
2014-12-27 11:48
O.pm
4.11
KB
-r--r--r--
2014-12-27 11:48
Opcode.pm
15.33
KB
-r--r--r--
2014-12-27 11:49
POSIX.pm
16.44
KB
-r--r--r--
2014-12-27 11:49
POSIX.pod
65.45
KB
-r--r--r--
2014-12-27 11:49
PerlIO.pm
10.21
KB
-r--r--r--
2014-12-27 11:48
SDBM_File.pm
3.46
KB
-r--r--r--
2014-12-27 11:49
Safe.pm
24.27
KB
-r--r--r--
2014-12-27 11:49
SelectSaver.pm
1.05
KB
-r--r--r--
2014-12-27 11:48
SelectSaver.t
365
B
-r--r--r--
2014-12-27 11:48
SelfLoader.pm
16.94
KB
-r--r--r--
2014-12-27 11:49
Socket.pm
35.47
KB
-r--r--r--
2014-12-27 11:49
Storable.pm
42.13
KB
-r--r--r--
2015-01-15 22:12
Symbol.pm
4.68
KB
-r--r--r--
2014-12-27 11:48
Symbol.t
2.52
KB
-r--r--r--
2014-12-27 11:48
Test.pm
28.12
KB
-r--r--r--
2014-12-27 11:48
Thread.pm
8.09
KB
-r--r--r--
2014-12-27 11:48
Thread.t
1.59
KB
-r--r--r--
2014-12-27 11:48
UNIVERSAL.pm
6.97
KB
-r--r--r--
2014-12-27 11:49
XSLoader.pm
9.99
KB
-r--r--r--
2016-10-10 17:38
_charnames.pm
31.63
KB
-r--r--r--
2014-12-27 11:49
arybase.pm
2.75
KB
-r--r--r--
2014-12-27 11:49
attributes.pm
15.95
KB
-r--r--r--
2014-12-27 12:30
autodie.pm
11.9
KB
-r--r--r--
2014-12-27 11:49
autouse.pm
4.14
KB
-r--r--r--
2014-12-27 11:48
base.pm
7.21
KB
-r--r--r--
2014-12-27 11:48
bigint.pm
18.29
KB
-r--r--r--
2014-12-27 11:49
bignum.pm
17.7
KB
-r--r--r--
2014-12-27 11:49
bigrat.pm
13.58
KB
-r--r--r--
2014-12-27 11:49
blib.pm
2.04
KB
-r--r--r--
2014-12-27 11:48
blib.t
1.81
KB
-r--r--r--
2014-12-27 11:48
buildcustomize.pl
1.1
KB
-rw-r--r--
2016-10-10 17:36
bytes.pm
2.96
KB
-r--r--r--
2014-12-27 11:48
bytes.t
2.78
KB
-r--r--r--
2014-12-27 11:48
bytes_heavy.pl
758
B
-r--r--r--
2014-12-27 11:48
charnames.pm
20.39
KB
-r--r--r--
2014-12-27 11:49
charnames.t
372.58
KB
-r--r--r--
2014-12-27 11:49
constant.pm
13.99
KB
-r--r--r--
2014-12-27 11:49
dbm_filter_util.pl
1.83
KB
-r--r--r--
2014-12-27 11:48
deprecate.pm
3.01
KB
-r--r--r--
2014-12-27 11:48
diagnostics.pm
18.26
KB
-r--r--r--
2014-12-27 11:48
diagnostics.t
7.1
KB
-r--r--r--
2014-12-27 11:49
dumpvar.pl
15.24
KB
-r--r--r--
2014-12-27 11:48
dumpvar.t
5.81
KB
-r--r--r--
2014-12-27 11:48
encoding.pm
20.04
KB
-r--r--r--
2014-12-27 11:49
experimental.pm
3.88
KB
-r--r--r--
2014-12-27 11:49
feature.pm
13.46
KB
-rw-r--r--
2014-12-27 12:46
feature.t
78
B
-r--r--r--
2014-12-27 11:48
fields.pm
9.24
KB
-r--r--r--
2014-12-27 11:48
filetest.pm
3.91
KB
-r--r--r--
2014-12-27 11:48
filetest.t
3
KB
-r--r--r--
2014-12-27 11:48
h2ph.t
1.58
KB
-r--r--r--
2014-12-27 11:48
h2xs.t
7.64
KB
-r--r--r--
2014-12-27 11:48
if.pm
2.63
KB
-r--r--r--
2014-12-27 11:48
integer.pm
3.18
KB
-r--r--r--
2014-12-27 11:48
integer.t
1.32
KB
-r--r--r--
2014-12-27 11:48
less.pm
3.13
KB
-r--r--r--
2014-12-27 11:48
less.t
901
B
-r--r--r--
2014-12-27 11:48
lib.pm
5.87
KB
-r--r--r--
2016-10-10 17:37
locale.pm
2.13
KB
-r--r--r--
2014-12-27 11:49
locale.t
72.86
KB
-r--r--r--
2014-12-27 11:49
mro.pm
9.86
KB
-r--r--r--
2014-12-27 11:49
open.pm
7.83
KB
-r--r--r--
2014-12-27 11:48
open.t
6.4
KB
-r--r--r--
2014-12-27 11:48
ops.pm
997
B
-r--r--r--
2014-12-27 11:48
overload.pm
51.41
KB
-r--r--r--
2014-12-27 11:49
overload.t
71.98
KB
-r--r--r--
2014-12-27 11:49
overload64.t
8.33
KB
-r--r--r--
2014-12-27 11:48
overloading.pm
1.77
KB
-r--r--r--
2014-12-27 11:48
overloading.t
3.25
KB
-r--r--r--
2014-12-27 11:48
parent.pm
2.83
KB
-r--r--r--
2014-12-27 11:48
perl5db.pl
307.01
KB
-r--r--r--
2014-12-27 11:49
perl5db.t
56.06
KB
-r--r--r--
2014-12-27 11:49
perldoc.pod
8.69
KB
-r--r--r--
2014-12-27 11:48
perlfaq.pm
94
B
-r--r--r--
2014-12-27 11:49
perlfaq.pod
22.18
KB
-r--r--r--
2014-12-27 11:48
perlfaq1.pod
14.36
KB
-r--r--r--
2014-12-27 11:49
perlfaq2.pod
9.24
KB
-r--r--r--
2014-12-27 11:49
perlfaq3.pod
37.67
KB
-r--r--r--
2014-12-27 11:48
perlfaq4.pod
87.39
KB
-r--r--r--
2014-12-27 11:49
perlfaq5.pod
54.11
KB
-r--r--r--
2014-12-27 11:49
perlfaq6.pod
38.66
KB
-r--r--r--
2014-12-27 11:49
perlfaq7.pod
36.98
KB
-r--r--r--
2014-12-27 11:49
perlfaq8.pod
48.9
KB
-r--r--r--
2014-12-27 11:48
perlfaq9.pod
14.7
KB
-r--r--r--
2014-12-27 11:48
perlglossary.pod
133.98
KB
-r--r--r--
2014-12-27 11:48
perlxs.pod
76.6
KB
-r--r--r--
2014-12-27 11:49
perlxstut.pod
48.91
KB
-r--r--r--
2014-12-27 11:48
perlxstypemap.pod
23.02
KB
-r--r--r--
2014-12-27 11:49
re.pm
17.55
KB
-r--r--r--
2014-12-27 11:49
sigtrap.pm
7.44
KB
-r--r--r--
2014-12-27 11:48
sigtrap.t
2.65
KB
-r--r--r--
2014-12-27 11:48
sort.pm
5.94
KB
-r--r--r--
2014-12-27 11:48
sort.t
5.54
KB
-r--r--r--
2014-12-27 11:49
strict.pm
3.83
KB
-r--r--r--
2014-12-27 11:49
strict.t
439
B
-r--r--r--
2014-12-27 11:49
subs.pm
848
B
-r--r--r--
2014-12-27 11:48
subs.t
79
B
-r--r--r--
2014-12-27 11:48
threads.pm
34.93
KB
-r--r--r--
2014-12-27 11:49
utf8.pm
7.64
KB
-r--r--r--
2014-12-27 11:49
utf8.t
21.67
KB
-r--r--r--
2014-12-27 11:48
utf8_heavy.pl
31
KB
-r--r--r--
2014-12-27 11:49
vars.pm
2.36
KB
-r--r--r--
2014-12-27 11:48
vars.t
2.68
KB
-r--r--r--
2014-12-27 11:48
vars_carp.t
246
B
-r--r--r--
2014-12-27 11:48
version.pm
1.58
KB
-r--r--r--
2014-12-27 11:48
version.pod
9.62
KB
-r--r--r--
2014-12-27 11:48
vmsish.pm
4.21
KB
-r--r--r--
2014-12-27 11:48
vmsish.t
7.21
KB
-r--r--r--
2014-12-27 11:48
warnings.pm
38.5
KB
-rw-r--r--
2014-12-27 11:49
warnings.t
120
B
-r--r--r--
2014-12-27 11:48
Save
Rename
#!./perl -w BEGIN { chdir 't' if -d 't'; @INC = ('../lib'); } use warnings; use strict; use vars qw($foo $bar $baz $ballast); use Test::More tests => 195; use Benchmark qw(:all); my $DELTA = 0.4; # Some timing ballast sub fib { my $n = shift; return $n if $n < 2; fib($n-1) + fib($n-2); } $ballast = 15; my $All_Pattern = qr/(\d+) +wallclock secs? +\( *(-?\d+\.\d\d) +usr +(-?\d+\.\d\d) +sys +\+ +(-?\d+\.\d\d) +cusr +(-?\d+\.\d\d) +csys += +(-?\d+\.\d\d) +CPU\)/; my $Noc_Pattern = qr/(\d+) +wallclock secs? +\( *(-?\d+\.\d\d) +usr +\+ +(-?\d+\.\d\d) +sys += +(-?\d+\.\d\d) +CPU\)/; my $Nop_Pattern = qr/(\d+) +wallclock secs? +\( *(-?\d+\.\d\d) +cusr +\+ +(-?\d+\.\d\d) +csys += +\d+\.\d\d +CPU\)/; # Please don't trust the matching parentheses to be useful in this :-) my $Default_Pattern = qr/$All_Pattern|$Noc_Pattern/; # see if the ratio of two integer values is within (1+$delta) sub cmp_delta { my ($min, $max, $delta) = @_; ($min, $max) = ($max, $min) if $max < $min; return 0 if $min < 1; # avoid / 0 return $max/$min <= (1+$delta); } my $t0 = new Benchmark; isa_ok ($t0, 'Benchmark', "Ensure we can create a benchmark object"); # We use the benchmark object once we've done some work: isa_ok(timeit(5, sub {++$foo}), 'Benchmark', "timeit CODEREF"); is ($foo, 5, "benchmarked code was run 5 times"); isa_ok(timeit(5, '++$bar'), 'Benchmark', "timeit eval"); is ($bar, 5, "benchmarked code was run 5 times"); # is coderef called with spurious arguments? timeit( 1, sub { $foo = @_ }); is ($foo, 0, "benchmarked code called without arguments"); print "# Burning CPU to benchmark things; will take time...\n"; # We need to do something fairly slow in the coderef. # Same coderef. Same place in memory. my $coderef = sub {$baz += fib($ballast)}; # The default is three. $baz = 0; my $threesecs = countit(0, $coderef); isa_ok($threesecs, 'Benchmark', "countit 0, CODEREF"); isnt ($baz, 0, "benchmarked code was run"); my $in_threesecs = $threesecs->iters; print "# in_threesecs=$in_threesecs iterations\n"; ok ($in_threesecs > 0, "iters returned positive iterations"); my $cpu3 = $threesecs->[1]; # user my $sys3 = $threesecs->[2]; # sys cmp_ok($cpu3+$sys3, '>=', 3.0, "3s cpu3 is at least 3s"); my $in_threesecs_adj = $in_threesecs; $in_threesecs_adj *= (3/$cpu3); # adjust because may not have run for exactly 3s print "# in_threesecs_adj=$in_threesecs_adj adjusted iterations\n"; my $estimate = int (100 * $in_threesecs_adj / 3) / 100; print "# from the 3 second run estimate $estimate iterations in 1 second...\n"; $baz = 0; my $onesec = countit(1, $coderef); isa_ok($onesec, 'Benchmark', "countit 1, CODEREF"); isnt ($baz, 0, "benchmarked code was run"); my $in_onesec = $onesec->iters; print "# in_onesec=$in_onesec iterations\n"; ok ($in_onesec > 0, "iters returned positive iterations"); my $cpu1 = $onesec->[1]; # user my $sys1 = $onesec->[2]; # sys cmp_ok($cpu1+$sys1, '>=', 1.0, "is cpu1 is at least 1s"); my $in_onesec_adj = $in_onesec; $in_onesec_adj *= (1/$cpu1); # adjust because may not have run for exactly 1s print "# in_onesec_adj=$in_onesec_adj adjusted iterations\n"; # I found that the eval'ed version was 3 times faster than the coderef. # (now it has a different ballast value) $baz = 0; my $again = countit(1, '$baz += fib($ballast)'); isa_ok($onesec, 'Benchmark', "countit 1, eval"); isnt ($baz, 0, "benchmarked code was run"); my $in_again = $again->iters; print "# $in_again iterations\n"; ok ($in_again > 0, "iters returned positive iterations"); my $t1 = new Benchmark; isa_ok ($t1, 'Benchmark', "Create another benchmark object now we're finished"); my $diff = timediff ($t1, $t0); isa_ok ($diff, 'Benchmark', "Get the time difference"); isa_ok (timesum ($t0, $t1), 'Benchmark', "check timesum"); my $default = timestr ($diff); isnt ($default, '', 'timestr ($diff)'); my $auto = timestr ($diff, 'auto'); is ($auto, $default, 'timestr ($diff, "auto") matches timestr ($diff)'); { my $all = timestr ($diff, 'all'); like ($all, $All_Pattern, 'timestr ($diff, "all")'); print "# $all\n"; my ($wallclock, $usr, $sys, $cusr, $csys, $cpu) = $all =~ $All_Pattern; is (timestr ($diff, 'none'), '', "none suppresses output"); my $noc = timestr ($diff, 'noc'); like ($noc, qr/$wallclock +wallclock secs? +\( *$usr +usr +\+ +$sys +sys += +\d+\.\d\d +CPU\)/, 'timestr ($diff, "noc")'); my $nop = timestr ($diff, 'nop'); like ($nop, qr/$wallclock +wallclock secs? +\( *$cusr +cusr +\+ +$csys +csys += +\d+\.\d\d +CPU\)/, 'timestr ($diff, "nop")'); if ($auto eq $noc) { pass ('"auto" is "noc"'); } else { is ($auto, $all, '"auto" isn\'t "noc", so should be eq to "all"'); } like (timestr ($diff, 'all', 'E'), qr/(\d+) +wallclock secs? +\( *\d\.\d+E[-+]?\d\d\d? +usr +\d\.\d+E[-+]?\d\d\d? +sys +\+ +\d\.\d+E[-+]?\d\d\d? +cusr +\d\.\d+E[-+]?\d\d\d? +csys += +\d\.\d+E[-+]?\d\d\d? +CPU\)/, 'timestr ($diff, "all", "E") [sprintf format of "E"]'); } my $out = tie *OUT, 'TieOut'; my $iterations = 3; $foo = 0; select(OUT); my $got = timethis($iterations, sub {++$foo}); select(STDOUT); isa_ok($got, 'Benchmark', "timethis CODEREF"); is ($foo, $iterations, "benchmarked code was run $iterations times"); $got = $out->read(); like ($got, qr/^timethis $iterations/, 'default title'); like ($got, $Default_Pattern, 'default format is all or noc'); $bar = 0; select(OUT); $got = timethis($iterations, '++$bar'); select(STDOUT); isa_ok($got, 'Benchmark', "timethis eval"); is ($bar, $iterations, "benchmarked code was run $iterations times"); $got = $out->read(); like ($got, qr/^timethis $iterations/, 'default title'); like ($got, $Default_Pattern, 'default format is all or noc'); my $title = 'lies, damn lies and benchmarks'; $foo = 0; select(OUT); $got = timethis($iterations, sub {++$foo}, $title); select(STDOUT); isa_ok($got, 'Benchmark', "timethis with title"); is ($foo, $iterations, "benchmarked code was run $iterations times"); $got = $out->read(); like ($got, qr/^$title:/, 'specify title'); like ($got, $Default_Pattern, 'default format is all or noc'); # default is auto, which is all or noc. nop can never match the default $foo = 0; select(OUT); $got = timethis($iterations, sub {++$foo}, $title, 'nop'); select(STDOUT); isa_ok($got, 'Benchmark', "timethis with format"); is ($foo, $iterations, "benchmarked code was run $iterations times"); $got = $out->read(); like ($got, qr/^$title:/, 'specify title'); like ($got, $Nop_Pattern, 'specify format as nop'); { $foo = 0; select(OUT); my $start = time; $got = timethis(-2, sub {$foo+= fib($ballast)}, $title, 'none'); my $end = time; select(STDOUT); isa_ok($got, 'Benchmark', "timethis, at least 2 seconds with format 'none'"); ok ($foo > 0, "benchmarked code was run"); ok ($end - $start > 1, "benchmarked code ran for over 1 second"); $got = $out->read(); # Remove any warnings about having too few iterations. $got =~ s/\(warning:[^\)]+\)//gs; $got =~ s/^[ \t\n]+//s; # Remove all the whitespace from the beginning is ($got, '', "format 'none' should suppress output"); } $foo = $bar = $baz = 0; select(OUT); $got = timethese($iterations, { Foo => sub {++$foo}, Bar => '++$bar', Baz => sub {++$baz} }); select(STDOUT); is(ref ($got), 'HASH', "timethese should return a hashref"); isa_ok($got->{Foo}, 'Benchmark', "Foo value"); isa_ok($got->{Bar}, 'Benchmark', "Bar value"); isa_ok($got->{Baz}, 'Benchmark', "Baz value"); eq_set([keys %$got], [qw(Foo Bar Baz)], 'should be exactly three objects'); is ($foo, $iterations, "Foo code was run $iterations times"); is ($bar, $iterations, "Bar code was run $iterations times"); is ($baz, $iterations, "Baz code was run $iterations times"); $got = $out->read(); # Remove any warnings about having too few iterations. $got =~ s/\(warning:[^\)]+\)//gs; like ($got, qr/timing $iterations iterations of\s+Bar\W+Baz\W+Foo\W*?\.\.\./s, 'check title'); # Remove the title $got =~ s/.*\.\.\.//s; like ($got, qr/\bBar\b.*\bBaz\b.*\bFoo\b/s, 'check output is in sorted order'); like ($got, $Default_Pattern, 'should find default format somewhere'); { # ensure 'use strict' does not leak from Benchmark.pm into benchmarked code no strict; select OUT; eval { timethese( 1, { undeclared_var => q{ $i++; $i-- }, symbolic_ref => q{ $bar = 42; $foo = 'bar'; $q = ${$foo} }, }, 'none' ); }; is( $@, '', q{no strict leakage in name => 'code'} ); eval { timethese( 1, { undeclared_var => sub { $i++; $i-- }, symbolic_ref => sub { $bar = 42; $foo = 'bar'; return ${$foo} }, }, 'none' ); }; is( $@, '', q{no strict leakage in name => sub { code }} ); # clear out buffer $out->read; } my $code_to_test = { Foo => sub {$foo+=fib($ballast-2)}, Bar => sub {$bar+=fib($ballast)}}; # Keep these for later. my $results; { $foo = $bar = 0; select(OUT); my $start = times; $results = timethese(-0.1, $code_to_test, 'none'); my $end = times; select(STDOUT); is(ref ($results), 'HASH', "timethese should return a hashref"); isa_ok($results->{Foo}, 'Benchmark', "Foo value"); isa_ok($results->{Bar}, 'Benchmark', "Bar value"); eq_set([keys %$results], [qw(Foo Bar)], 'should be exactly two objects'); ok ($foo > 0, "Foo code was run"); ok ($bar > 0, "Bar code was run"); ok (($end - $start) > 0.1, "benchmarked code ran for over 0.1 seconds"); $got = $out->read(); # Remove any warnings about having too few iterations. $got =~ s/\(warning:[^\)]+\)//gs; is ($got =~ tr/ \t\n//c, 0, "format 'none' should suppress output"); } my $graph_dissassembly = qr!^[ \t]+(\S+)[ \t]+(\w+)[ \t]+(\w+)[ \t]* # Title line \n[ \t]*(\w+)[ \t]+([0-9.]+(?:/s)?)[ \t]+(-+)[ \t]+(-?\d+%)[ \t]* \n[ \t]*(\w+)[ \t]+([0-9.]+(?:/s)?)[ \t]+(-?\d+%)[ \t]+(-+)[ \t]*$!xm; sub check_graph_consistency { my ( $ratetext, $slowc, $fastc, $slowr, $slowratet, $slowslow, $slowfastt, $fastr, $fastratet, $fastslowt, $fastfast) = @_; note("calling check_graph_consistency from line " . (caller(1))[2]); my $all_passed = 1; $all_passed &= is ($slowc, $slowr, "left col tag should be top row tag"); $all_passed &= is ($fastc, $fastr, "right col tag should be bottom row tag"); $all_passed &= like ($slowslow, qr/^-+/, "should be dash for comparing slow with slow"); $all_passed &= is ($slowslow, $fastfast, "slow v slow should be same as fast v fast"); my $slowrate = $slowratet; my $fastrate = $fastratet; my ($slow_is_rate, $fast_is_rate); unless ($slow_is_rate = $slowrate =~ s!/s!!) { # Slow is expressed as iters per second. $slowrate = 1/$slowrate if $slowrate; } unless ($fast_is_rate = $fastrate =~ s!/s!!) { # Fast is expressed as iters per second. $fastrate = 1/$fastrate if $fastrate; } if ($ratetext =~ /rate/i) { $all_passed &= ok ($slow_is_rate, "slow should be expressed as a rate"); $all_passed &= ok ($fast_is_rate, "fast should be expressed as a rate"); } else { $all_passed &= ok (!$slow_is_rate, "slow should be expressed as a iters per second"); $all_passed &= ok (!$fast_is_rate, "fast should be expressed as a iters per second"); } (my $slowfast = $slowfastt) =~ s!%!!; (my $fastslow = $fastslowt) =~ s!%!!; if ($slowrate < $fastrate) { pass ("slow rate is less than fast rate"); unless (ok ($slowfast <= 0 && $slowfast >= -100, "slowfast should be less than or equal to zero, and >= -100")) { print STDERR "# slowfast $slowfast\n"; $all_passed = 0; } unless (ok ($fastslow > 0, "fastslow should be > 0")) { print STDERR "# fastslow $fastslow\n"; $all_passed = 0; } } else { $all_passed &= is ($slowrate, $fastrate, "slow rate isn't less than fast rate, so should be the same"); # In OpenBSD the $slowfast is sometimes a really, really, really # small number less than zero, and this gets stringified as -0. $all_passed &= like ($slowfast, qr/^-?0$/, "slowfast should be zero"); $all_passed &= like ($fastslow, qr/^-?0$/, "fastslow should be zero"); } return $all_passed; } sub check_graph_vs_output { my ($chart, $got) = @_; my ( $ratetext, $slowc, $fastc, $slowr, $slowratet, $slowslow, $slowfastt, $fastr, $fastratet, $fastslowt, $fastfast) = $got =~ $graph_dissassembly; my $all_passed = check_graph_consistency ( $ratetext, $slowc, $fastc, $slowr, $slowratet, $slowslow, $slowfastt, $fastr, $fastratet, $fastslowt, $fastfast); $all_passed &= is_deeply ($chart, [['', $ratetext, $slowc, $fastc], [$slowr, $slowratet, $slowslow, $slowfastt], [$fastr, $fastratet, $fastslowt, $fastfast]], "check the chart layout matches the formatted output"); unless ($all_passed) { print STDERR "# Something went wrong there. I got this chart:\n"; print STDERR "# $_\n" foreach split /\n/, $got; } } sub check_graph { my ($title, $row1, $row2) = @_; is (scalar @$title, 4, "Four entries in title row"); is (scalar @$row1, 4, "Four entries in first row"); is (scalar @$row2, 4, "Four entries in second row"); is (shift @$title, '', "First entry of output graph should be ''"); check_graph_consistency (@$title, @$row1, @$row2); } { select(OUT); my $start = times; my $chart = cmpthese( -0.1, { a => "\$i = sqrt(\$i++) * sqrt(\$i)", b => "\$i = sqrt(\$i++)", }, "auto" ) ; my $end = times; select(STDOUT); ok (($end - $start) > 0.05, "benchmarked code ran for over 0.05 seconds"); $got = $out->read(); # Remove any warnings about having too few iterations. $got =~ s/\(warning:[^\)]+\)//gs; like ($got, qr/running\W+a\W+b.*?for at least 0\.1 CPU second/s, 'check title'); # Remove the title $got =~ s/.*\.\.\.//s; like ($got, $Default_Pattern, 'should find default format somewhere'); like ($got, $graph_dissassembly, "Should find the output graph somewhere"); check_graph_vs_output ($chart, $got); } # Not giving auto should suppress timethese results. { select(OUT); my $start = times; my $chart = cmpthese( -0.1, { a => "\$i = sqrt(\$i++) * sqrt(\$i)", b => "\$i = sqrt(\$i++)" }); my $end = times; select(STDOUT); ok (($end - $start) > 0.05, "benchmarked code ran for over 0.05 seconds"); $got = $out->read(); # Remove any warnings about having too few iterations. $got =~ s/\(warning:[^\)]+\)//gs; unlike ($got, qr/running\W+a\W+b.*?for at least 0\.1 CPU second/s, 'should not have title'); # Remove the title $got =~ s/.*\.\.\.//s; unlike ($got, $Default_Pattern, 'should not find default format somewhere'); like ($got, $graph_dissassembly, "Should find the output graph somewhere"); check_graph_vs_output ($chart, $got); } { $foo = $bar = 0; select(OUT); my $chart = cmpthese( 10, $code_to_test, 'nop' ) ; select(STDOUT); ok ($foo > 0, "Foo code was run"); ok ($bar > 0, "Bar code was run"); $got = $out->read(); # Remove any warnings about having too few iterations. $got =~ s/\(warning:[^\)]+\)//gs; like ($got, qr/timing 10 iterations of\s+Bar\W+Foo\W*?\.\.\./s, 'check title'); # Remove the title $got =~ s/.*\.\.\.//s; like ($got, $Nop_Pattern, 'specify format as nop'); like ($got, $graph_dissassembly, "Should find the output graph somewhere"); check_graph_vs_output ($chart, $got); } { $foo = $bar = 0; select(OUT); my $chart = cmpthese( 10, $code_to_test, 'none' ) ; select(STDOUT); ok ($foo > 0, "Foo code was run"); ok ($bar > 0, "Bar code was run"); $got = $out->read(); # Remove any warnings about having too few iterations. $got =~ s/\(warning:[^\)]+\)//gs; $got =~ s/^[ \t\n]+//s; # Remove all the whitespace from the beginning is ($got, '', "format 'none' should suppress output"); is (ref $chart, 'ARRAY', "output should be an array ref"); # Some of these will go bang if the preceding test fails. There will be # a big clue as to why, from the previous test's diagnostic is (ref $chart->[0], 'ARRAY', "output should be an array of arrays"); check_graph (@$chart); } { $foo = $bar = 0; select(OUT); my $chart = cmpthese( $results ) ; select(STDOUT); is ($foo, 0, "Foo code was not run"); is ($bar, 0, "Bar code was not run"); $got = $out->read(); ok ($got !~ /\.\.\./s, 'check that there is no title'); like ($got, $graph_dissassembly, "Should find the output graph somewhere"); check_graph_vs_output ($chart, $got); } { $foo = $bar = 0; select(OUT); my $chart = cmpthese( $results, 'none' ) ; select(STDOUT); is ($foo, 0, "Foo code was not run"); is ($bar, 0, "Bar code was not run"); $got = $out->read(); is ($got, '', "'none' should suppress all output"); is (ref $chart, 'ARRAY', "output should be an array ref"); # Some of these will go bang if the preceding test fails. There will be # a big clue as to why, from the previous test's diagnostic is (ref $chart->[0], 'ARRAY', "output should be an array of arrays"); check_graph (@$chart); } ###}my $out = tie *OUT, 'TieOut'; my ($got); ### my $debug = tie *STDERR, 'TieOut'; $bar = 0; isa_ok(timeit(5, '++$bar'), 'Benchmark', "timeit eval"); is ($bar, 5, "benchmarked code was run 5 times"); is ($debug->read(), '', "There was no debug output"); Benchmark->debug(1); $bar = 0; select(OUT); $got = timeit(5, '++$bar'); select(STDOUT); isa_ok($got, 'Benchmark', "timeit eval"); is ($bar, 5, "benchmarked code was run 5 times"); is ($out->read(), '', "There was no STDOUT output with debug enabled"); isnt ($debug->read(), '', "There was STDERR debug output with debug enabled"); Benchmark->debug(0); $bar = 0; isa_ok(timeit(5, '++$bar'), 'Benchmark', "timeit eval"); is ($bar, 5, "benchmarked code was run 5 times"); is ($debug->read(), '', "There was no debug output debug disabled"); undef $debug; untie *STDERR; # To check the cache we are poking where we don't belong, inside the namespace. # The way benchmark is written we can't actually check whether the cache is # being used, merely what's become cached. clearallcache(); my @before_keys = keys %Benchmark::Cache; $bar = 0; isa_ok(timeit(5, '++$bar'), 'Benchmark', "timeit eval"); is ($bar, 5, "benchmarked code was run 5 times"); my @after5_keys = keys %Benchmark::Cache; $bar = 0; isa_ok(timeit(10, '++$bar'), 'Benchmark', "timeit eval"); is ($bar, 10, "benchmarked code was run 10 times"); ok (!eq_array ([keys %Benchmark::Cache], \@after5_keys), "10 differs from 5"); clearcache(10); # Hash key order will be the same if there are the same keys. is_deeply ([keys %Benchmark::Cache], \@after5_keys, "cleared 10, only cached results for 5 should remain"); clearallcache(); is_deeply ([keys %Benchmark::Cache], \@before_keys, "back to square 1 when we clear the cache again?"); { # Check usage error messages my %usage = %Benchmark::_Usage; delete $usage{runloop}; # not public, not worrying about it just now my @takes_no_args = qw(clearallcache disablecache enablecache); my %cmpthese = ('forgot {}' => 'cmpthese( 42, foo => sub { 1 } )', 'not result' => 'cmpthese(42)', 'array ref' => 'cmpthese( 42, [ foo => sub { 1 } ] )', ); while( my($name, $code) = each %cmpthese ) { eval $code; is( $@, $usage{cmpthese}, "cmpthese usage: $name" ); } my %timethese = ('forgot {}' => 'timethese( 42, foo => sub { 1 } )', 'no code' => 'timethese(42)', 'array ref' => 'timethese( 42, [ foo => sub { 1 } ] )', ); while( my($name, $code) = each %timethese ) { eval $code; is( $@, $usage{timethese}, "timethese usage: $name" ); } while( my($func, $usage) = each %usage ) { next if grep $func eq $_, @takes_no_args; eval "$func()"; is( $@, $usage, "$func usage: no args" ); } foreach my $func (@takes_no_args) { eval "$func(42)"; is( $@, $usage{$func}, "$func usage: with args" ); } } package TieOut; sub TIEHANDLE { my $class = shift; bless(\( my $ref = ''), $class); } sub PRINT { my $self = shift; $$self .= join('', @_); } sub PRINTF { my $self = shift; $$self .= sprintf shift, @_; } sub read { my $self = shift; return substr($$self, 0, length($$self), ''); }