| 1 | package Bencher::Scenario::AppSorted; | ||
| 2 | |||
| 3 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |
| 4 | 1 | our $DATE = '2021-07-31'; # DATE | |
| 5 | 1 | our $DIST = 'Bencher-Scenario-AppSorted'; # DIST | |
| 6 | 1 | our $VERSION = '0.002'; # VERSION | |
| 7 | |||
| 8 | 1 | ▶ | use 5.010001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 1 | ▶ | use File::Slurper 'write_text'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 1 | ▶ | use File::Temp qw(tempdir); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | 1 | my $dir = tempdir(); | |
| 16 | 1 | write_text("$dir/100k-sorted" , join("", map {sprintf "%06d\n", $_} 1..100_000)); | |
| 17 | 1 | write_text("$dir/100k-unsorted-middle" , join("", map {sprintf "%06d\n", $_} 1..50_000, 50_002, 50_001, 50_003..100_000)); | |
| 18 | 1 | write_text("$dir/100k-unsorted-beginning", join("", map {sprintf "%06d\n", $_} 2,1, 3..100_000)); | |
| 19 | |||
| 20 | 1 | our $scenario = { | |
| 21 | summary => 'Benchmark sorted vs is-sorted', | ||
| 22 | participants => [ | ||
| 23 | {name=>"sorted" , module=>'App::sorted', cmdline_template=>'sorted <filename>; true'}, | ||
| 24 | {name=>"is-sorted", module=>'File::IsSorted', cmdline_template=>'is-sorted check <filename>; true'}, | ||
| 25 | ], | ||
| 26 | precision => 7, | ||
| 27 | datasets => [ | ||
| 28 | {name=>'100k-sorted', args=>{filename=>"$dir/100k-sorted"}}, | ||
| 29 | {name=>'100k-unsorted-middle', args=>{filename=>"$dir/100k-unsorted-middle"}}, | ||
| 30 | {name=>'100k-unsorted-beginning', args=>{filename=>"$dir/100k-unsorted-beginning"}}, | ||
| 31 | ], | ||
| 32 | }; | ||
| 33 | |||
| 34 | 1 | 1; | |
| 35 | # ABSTRACT: Benchmark sorted vs is-sorted | ||
| 36 | |||
| 37 | __END__ | ||