line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
3039
|
use 5.014; |
|
2
|
|
|
|
|
10
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Surveyor::Benchmark::SchwartzianTransform::SortFilesBySize; |
4
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
59
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
92
|
|
7
|
2
|
|
|
2
|
|
21
|
no warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
784
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.123'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=encoding utf8 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Surveyor::Benchmark::SchwartzianTransform::SortFilesBySize - Compare the low-tech and Schwartzian Transform sorts |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Use with C from L: |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
% survey -p Surveyor::Benchmark::SchwartzianTransform::SortFilesBySize '/glob/pattern/*' |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over 4 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item set_up |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub set_up { |
32
|
1
|
|
|
1
|
1
|
602
|
my( $self, @args ) = @_; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
3
|
my $glob = $args[0]; |
35
|
1
|
|
|
|
|
259
|
@L::files = glob $glob; |
36
|
1
|
|
|
|
|
43
|
print "Testing with " . @L::files . " files\n"; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
5
|
my $transform = q|map $_->[0], sort { $a->[1] <=> $b->[1] } map [ $_, -M ]|; |
39
|
1
|
|
|
|
|
3
|
my $sort = q|sort { -M $a <=> -M $b }|; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $code = { |
42
|
0
|
|
|
0
|
|
0
|
assign => sub { my @r = @L::files }, |
43
|
1
|
|
|
1
|
|
713
|
'glob' => sub { my @files = glob $glob }, |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
|
3751
|
sort_names => sub { sort { $a cmp $b } @L::files }, |
|
57
|
|
|
|
|
107
|
|
46
|
1
|
|
|
1
|
|
353
|
sort_names_assign => sub { my @r = sort { $a cmp $b } @L::files }, |
|
57
|
|
|
|
|
107
|
|
47
|
1
|
|
|
0
|
|
151
|
sort_times_assign => eval "sub { my \@r = $sort \@L::files }", |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
4165
|
|
|
65
|
|
|
|
|
151
|
|
|
1
|
|
|
|
|
792
|
|
|
65
|
|
|
|
|
134
|
|
|
1
|
|
|
|
|
677
|
|
|
65
|
|
|
|
|
1015
|
|
|
1
|
|
|
|
|
3294
|
|
|
65
|
|
|
|
|
1445
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
ordinary_orig => eval "sub { my \@r = $sort glob \$glob }", |
50
|
|
|
|
|
|
|
ordinary_mod => eval "sub { my \@r = $sort \@L::files }", |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
schwartz_orig => eval "sub { $transform, glob \$glob }", |
53
|
|
|
|
|
|
|
schwartz_orig_assign => eval "sub { my \@r = $transform, glob \$glob }", |
54
|
|
|
|
|
|
|
schwartz_mod => eval "sub { my \@r = $transform, \@L::files }", |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
8
|
foreach my $key ( keys %$code ) { |
58
|
2
|
|
|
2
|
|
17
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
273
|
|
59
|
10
|
|
|
|
|
22
|
*{"bench_$key"} = $code->{$key}; |
|
10
|
|
|
|
|
44
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item tear_down |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
|
sub tear_down { 1; } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item test |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub test { |
74
|
0
|
|
|
0
|
1
|
|
warn "I haven't defined tests yet"; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 TO DO |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SEE ALSO |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This source is in a Git repository: |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
https://github.com/briandfoy/surveyor-benchmark-schwartziantransform-sortfilesbysize |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
brian d foy, C<< >> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Copyright © 2013-2022, brian d foy . All rights reserved. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
You may redistribute this under the terms as Artistic License 2.0. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |