line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
####################################################################### |
3
|
|
|
|
|
|
|
# housekeeping |
4
|
|
|
|
|
|
|
####################################################################### |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Object::Exercise::Benchmark; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require 5.6.2; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1319
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
92
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
12
|
use File::Basename; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
226
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
2089
|
use Benchmark qw( :hireswallclock ); |
|
2
|
|
|
|
|
16567
|
|
|
2
|
|
|
|
|
15
|
|
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
350
|
use Object::Exercise::Common qw( log_message continue ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
19
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
######################################################################## |
19
|
|
|
|
|
|
|
# package variables |
20
|
|
|
|
|
|
|
######################################################################## |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = 1.00; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
######################################################################## |
25
|
|
|
|
|
|
|
# exported to caller |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
my $base = basename $0; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $t0 = Benchmark->new; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $obj = shift; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $count = 0; |
36
|
|
|
|
|
|
|
my $errors = 0; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
TEST: |
39
|
|
|
|
|
|
|
for( @_ ) |
40
|
|
|
|
|
|
|
{ |
41
|
|
|
|
|
|
|
if( ref $_ ) |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
++$count; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $argz = ref $_->[0] ? $_->[0] : $_; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $method = shift @$argz; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
eval { $obj->$method( @$argz ) }; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
next unless $@; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$log_message->( 'Error:', $@, 'Executing:', $method, $argz ); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
++$errors; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
last unless $continue; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $diff = timestr timediff $t0, Benchmark->new; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$log_message-> |
64
|
|
|
|
|
|
|
( |
65
|
|
|
|
|
|
|
"Benchmark $base: $diff", |
66
|
|
|
|
|
|
|
"Executing: $count items, $errors errors", |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |