blib/lib/Surveyor/Benchmark/SchwartzianTransform/SortFilesBySize.pm

filter: Statementstmt 85.7% 42 / 49 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 73.6% 14 / 19 Podpod 100% 3 / 3 totaltotal 83.1% 59 / 71 CC 2 SCAR 2.3
CC
2
Cov
86%
set_up
2.0
__ANON__
2.0
tear_down
2.0
CRAP 1.3
↑ Summary
1 3 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package Surveyor::Benchmark::SchwartzianTransform::SortFilesBySize;
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 our $VERSION = '0.125';
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<survey> from L<Surveyor::App>:
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 1 ▶sub set_up {
Subroutine set_up: called CC=2 SCAR=7.0
Pod documented
32 1 my( $self, @args ) = @_;
33  
34 1 my $glob = $args[0];
35 3 ▶ @L::files = glob $glob;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 print "Testing with " . @L::files . " files\n";
37  
38 1 my $transform = q|map $_->[0], sort { $a->[1] <=> $b->[1] } map [ $_, -M ]|;
39 1 my $sort = q|sort { -M $a <=> -M $b }|;
40  
41 my $code = {
42 0 ▶ assign => sub { my @r = @L::files },
Subroutine __ANON__: not called CC=1 SCAR=6.9
43 1 ▶ 'glob' => sub { my @files = glob $glob },
Subroutine __ANON__: called CC=1 SCAR=0.0
44  
45 1 ▶ sort_names => sub { sort { $a cmp $b } @L::files },
Subroutine __ANON__: called CC=1 SCAR=0.0
46 1 ▶ sort_names_assign => sub { my @r = sort { $a cmp $b } @L::files },
Subroutine __ANON__: called CC=1 SCAR=0.0
47 0 ▶ sort_times_assign => eval "sub { my \@r = $sort \@L::files }",
Subroutine __ANON__: not called CC=1 SCAR=0.3
Subroutine __ANON__: called CC=1 SCAR=0.3
Subroutine __ANON__: called CC=1 SCAR=0.3
Subroutine __ANON__: called CC=1 SCAR=0.3
Subroutine __ANON__: not called CC=1 SCAR=0.3
Subroutine __ANON__: called CC=1 SCAR=0.3
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 foreach my $key ( keys %$code ) {
58 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
59 10 *{"bench_$key"} = $code->{$key};
60 }
61 }
62  
63 =item tear_down
64  
65 =cut
66  
67 0 ▶sub tear_down { 1; }
Subroutine tear_down: not called CC=1 SCAR=6.9
Pod documented
68  
69 =item test
70  
71 =cut
72  
73 0 ▶sub test {
Subroutine test: not called CC=1 SCAR=6.9
Pod documented
74 0 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<< <briandfoy@pobox.com> >>
94  
95 =head1 COPYRIGHT AND LICENSE
96  
97 Copyright © 2013-2025, brian d foy <briandfoy@pobox.com>. All rights reserved.
98  
99 You may redistribute this under the terms as Artistic License 2.0.
100  
101 =cut
102  
103 3 1;
↑ Summary