File tree Expand file tree Collapse file tree 1 file changed +40
-2
lines changed Expand file tree Collapse file tree 1 file changed +40
-2
lines changed Original file line number Diff line number Diff line change 16
16
# ##############################################################################
17
17
# ##############################################################################
18
18
19
- my $num = 50;
20
- my $ignore = 1;
19
+ my $num = 50;
20
+ my $ignore = 1;
21
+ my $details = 1;
21
22
22
23
my $ok = GetOptions(
23
24
' num=i' => \$num ,
24
25
' ignore=i' => \$ignore ,
26
+ ' details!' => \$details ,
25
27
);
26
28
27
29
59
61
60
62
my $avg = int (average(@res ));
61
63
64
+ if ($details ) {
65
+ show_details(@res );
66
+ print " \n " ;
67
+ }
68
+
62
69
print " Ran '$cmd ' $num times with average completion time of $avg ms\n " ;
63
70
64
71
if ($exit != 0) {
68
75
# ##############################################################################
69
76
# ##############################################################################
70
77
78
+ sub show_details {
79
+ my @res = @_ ;
80
+
81
+ my $x = {};
82
+ my $max = 0;
83
+
84
+ # Build a hash of all the times:count
85
+ foreach my $time (@res ) {
86
+ $x -> {$time }++;
87
+
88
+ if ($x -> {$time } > $max ) {
89
+ $max = $x -> {$time };
90
+ }
91
+ }
92
+
93
+ my $target_width = 100; # How wide we want the bar + text
94
+ my $total = scalar (@res );
95
+ my $scale = ($target_width - 15) / $max ;
96
+
97
+ print " \n " ;
98
+
99
+ # Print out a basic histogram of the times
100
+ foreach my $time (sort (keys %$x )) {
101
+ my $count = $x -> {$time };
102
+ my $percent = sprintf (" %0 .1f" , ($count / $total ) * 100);
103
+
104
+ my $bar = " %" x ($count * $scale );
105
+ print " $time ms: $bar ($percent %)\n " ;
106
+ }
107
+ }
108
+
71
109
sub average {
72
110
my $ret = 0;
73
111
You can’t perform that action at this time.
0 commit comments