| 1 | package Benchmark::DKbench; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Digest; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use File::Spec::Functions; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use List::Util qw(min max sum); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Time::HiRes; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Time::Piece; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Astro::Coord::Constellations 'constellation_for_eq'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use Astro::Coord::Precession 'precess'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use Crypt::JWT qw(encode_jwt decode_jwt); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use CSS::Inliner; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use DBI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use File::ShareDir 'dist_dir'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use HTML::FormatText; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use HTML::TreeBuilder; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use Imager; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use Imager::Filter::Mandelbrot; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use Image::PHash; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | ▶ | use JSON::XS; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use Math::DCT ':all'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use Math::MatrixReal; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | use MCE::Loop; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | use SQL::Abstract::Classic; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | use SQL::Inserter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | use System::Info; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | ▶ | use Text::Levenshtein::Damerau::XS; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | ▶ | use Text::Levenshtein::XS; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | our @EXPORT = qw(system_identity suite_run calc_scalability); | |||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | our $datadir = dist_dir("Benchmark-DKbench"); | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | our $VERSION = '2.1'; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | Benchmark::DKbench - Perl CPU Benchmark | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | # Run the suite single-threaded and then multi-threaded on multi-core systems | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # Will print scores for the two runs and multi/single thread scalability | ||||||||||||||||||||||||||||||||||||||||||
| 50 | dkbench | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | # A dual-thread "quick" run (with times instead of scores) | ||||||||||||||||||||||||||||||||||||||||||
| 53 | dkbench -j 2 -q | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | # If BioPerl is installed, enable the BioPerl benchmarks by downloading Genbank data | ||||||||||||||||||||||||||||||||||||||||||
| 56 | dkbench --setup | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | # Force install the reference versions of all CPAN modules | ||||||||||||||||||||||||||||||||||||||||||
| 59 | setup_dkbench --force | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | A Perl benchmark suite for general compute, created to evaluate the comparative | ||||||||||||||||||||||||||||||||||||||||||
| 64 | performance of systems when running computationally intensive Perl (both pure Perl | ||||||||||||||||||||||||||||||||||||||||||
| 65 | and C/XS) workloads. It is a good overall indicator for generic CPU performance in | ||||||||||||||||||||||||||||||||||||||||||
| 66 | real-world scenarios. It runs single and multi-threaded (able to scale to hundreds | ||||||||||||||||||||||||||||||||||||||||||
| 67 | of CPUs) and can be fully customized to run the benchmarks that better suit your own | ||||||||||||||||||||||||||||||||||||||||||
| 68 | scenario. | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | =head1 INSTALLATION | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | The only non-CPAN software required to install/run the suite is a build environment | ||||||||||||||||||||||||||||||||||||||||||
| 73 | for the C/XS modules (C compiler, make etc.) and Perl. On the most popular Linux | ||||||||||||||||||||||||||||||||||||||||||
| 74 | package managers you can easily set up such an environment (as root or with sudo): | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | # Debian/Ubuntu etc | ||||||||||||||||||||||||||||||||||||||||||
| 77 | apt-get update | ||||||||||||||||||||||||||||||||||||||||||
| 78 | apt-get -y install build-essential perl cpanminus | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | # CentOS/Red Hat | ||||||||||||||||||||||||||||||||||||||||||
| 81 | yum update | ||||||||||||||||||||||||||||||||||||||||||
| 82 | yum -y install gcc make patch perl perl-App-cpanminus | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | After that, you can use L<App::cpanminus> to install the benchmark suite (as | ||||||||||||||||||||||||||||||||||||||||||
| 85 | root/sudo is the easiest, will install for all users): | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | cpanm -n Benchmark::DKbench | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | See the C<setup_dkbench> script below for more on the installation of a couple of | ||||||||||||||||||||||||||||||||||||||||||
| 90 | optional benchmarks and standardizing your benchmarking environment. | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | =head1 SCRIPTS | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | You will most likely only ever need the main script C<dkbench> which launches the | ||||||||||||||||||||||||||||||||||||||||||
| 95 | suite, although C<setup_dkbench> can help with setup or standardizing/normalizing your | ||||||||||||||||||||||||||||||||||||||||||
| 96 | benchmarking environment. | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | =head2 C<dkbench> | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | The main script that runs the DKbench benchmark suite. If L<BioPerl> is installed, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | you may want to start with C<dkbench --setup>. But beyond that, there are many | ||||||||||||||||||||||||||||||||||||||||||
| 102 | options to control number of threads, iterations, which benchmarks to run etc: | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | dkbench [options] | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | Options: | ||||||||||||||||||||||||||||||||||||||||||
| 107 | --threads <i>, -j <i> : Number of benchmark threads (default is 1). | ||||||||||||||||||||||||||||||||||||||||||
| 108 | --multi, -m : Multi-threaded using all your CPU cores/threads. | ||||||||||||||||||||||||||||||||||||||||||
| 109 | --max_threads <i> : Override the cpu detection to specify max cpu threads. | ||||||||||||||||||||||||||||||||||||||||||
| 110 | --iter <i>, -i <i> : Number of suite iterations (with min/max/avg at the end). | ||||||||||||||||||||||||||||||||||||||||||
| 111 | --include <regex> : Run only benchmarks that match regex. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | --exclude <regex> : Do not run benchmarks that match regex. | ||||||||||||||||||||||||||||||||||||||||||
| 113 | --time, -t : Report time (sec) instead of score. | ||||||||||||||||||||||||||||||||||||||||||
| 114 | --quick, -q : Quick benchmark run (implies -t). | ||||||||||||||||||||||||||||||||||||||||||
| 115 | --no_mce : Do not run under MCE::Loop (implies -j 1). | ||||||||||||||||||||||||||||||||||||||||||
| 116 | --skip_bio : Skip BioPerl benchmarks. | ||||||||||||||||||||||||||||||||||||||||||
| 117 | --skip_timep : Skip Time::Piece benchmark (see benchmark details). | ||||||||||||||||||||||||||||||||||||||||||
| 118 | --skip_prove : Skip Moose prove benchmark. | ||||||||||||||||||||||||||||||||||||||||||
| 119 | --bio_codons : Run optional BioPerl Codons benchmark (does not scale well). | ||||||||||||||||||||||||||||||||||||||||||
| 120 | --sleep <i> : Sleep for <i> secs after each benchmark. | ||||||||||||||||||||||||||||||||||||||||||
| 121 | --setup : Download the Genbank data to enable the BioPerl tests. | ||||||||||||||||||||||||||||||||||||||||||
| 122 | --datapath <path> : Override the path where the expected benchmark data is found. | ||||||||||||||||||||||||||||||||||||||||||
| 123 | --ver <num> : Skip benchmarks added after the specified version. | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | The default run (no options) will run all the benchmarks both single-threaded and | ||||||||||||||||||||||||||||||||||||||||||
| 126 | multi-threaded (using all detected CPU cores/hyperthreads) and show you scores and | ||||||||||||||||||||||||||||||||||||||||||
| 127 | multi vs single threaded scalability. | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | The scores are calibrated such that a reference CPU (Intel Xeon Platinum 8481C - | ||||||||||||||||||||||||||||||||||||||||||
| 130 | Sapphire Rapids) would achieve a score of 1000 in a single-core benchmark run using | ||||||||||||||||||||||||||||||||||||||||||
| 131 | the default software configuration (Linux/Perl 5.36.0 with reference CPAN modules). | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | The multi-thread scalability should approach 100% if each thread runs on a full core | ||||||||||||||||||||||||||||||||||||||||||
| 134 | (i.e. no SMT), and the core can maintain the clock speed it had on the single-thread | ||||||||||||||||||||||||||||||||||||||||||
| 135 | runs. Note that the overall scalability is an average of the benchmarks that drops | ||||||||||||||||||||||||||||||||||||||||||
| 136 | non-scaling outliers (over 2*stdev less than the mean). | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | The suite will report a Pass/Fail per benchmark. A failure may be caused if you have | ||||||||||||||||||||||||||||||||||||||||||
| 139 | different CPAN module version installed - this is normal, and you will be warned. | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | The suite uses L<MCE::Loop> to run on the desired number of parallel threads, although | ||||||||||||||||||||||||||||||||||||||||||
| 142 | there is an option to disable it, which forces a single-thread run. | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | =head2 C<setup_dkbench> | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | Simple installer to check/get the reference versions of CPAN modules and download | ||||||||||||||||||||||||||||||||||||||||||
| 147 | the Genbank data file required for the BioPerl benchmarks of the DKbench suite. | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | It assumes that you have some software already installed (see INSTALLATION above), | ||||||||||||||||||||||||||||||||||||||||||
| 150 | try C<setup_dkbench --help> will give you more details. | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | setup_dkbench [--force --sudo --test --data=s --help] | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | Options: | ||||||||||||||||||||||||||||||||||||||||||
| 155 | --sudo : Will use sudo for cpanm calls. | ||||||||||||||||||||||||||||||||||||||||||
| 156 | --force : Will install reference CPAN module versions and re-download the genbank data. | ||||||||||||||||||||||||||||||||||||||||||
| 157 | --test : Will run the test suites for the CPAN module (default behaviour is to skip). | ||||||||||||||||||||||||||||||||||||||||||
| 158 | --data=s : Data dir path to copy files from. Should not need if you installed DKbench. | ||||||||||||||||||||||||||||||||||||||||||
| 159 | --help : Print this help text and exit. | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | Running it without any options will fetch the data for the BioPerl tests (similar to | ||||||||||||||||||||||||||||||||||||||||||
| 162 | C<dkbench --setup>) and use C<cpanm> to install any missing libraries. | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | Using it with C<--force> will install the reference CPAN module versions, including | ||||||||||||||||||||||||||||||||||||||||||
| 165 | BioPerl which is not a requirement for DKbench, but enables the BioPerl benchmarks. | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | The reference Perl and CPAN versions are suggested if you want a fair comparison | ||||||||||||||||||||||||||||||||||||||||||
| 168 | between systems and also for the benchmark Pass/Fail results to be reliable. | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | =head1 BENCHMARKS | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | The suite consists of 21 benchmarks, 20 will run by default. However, the | ||||||||||||||||||||||||||||||||||||||||||
| 173 | C<BioPerl Monomers> requires the optional L<BioPerl> to be installed and Genbank | ||||||||||||||||||||||||||||||||||||||||||
| 174 | data to be downloaded (C<dkbench --setup> can do the latter), so you will only | ||||||||||||||||||||||||||||||||||||||||||
| 175 | see 19 benchmarks running just after a standard install. Because the overall score | ||||||||||||||||||||||||||||||||||||||||||
| 176 | is an average, it is generally unaffected by skipping a benchmark or two. | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | On MacOS only, the C<Time::Piece> benchmark will be skipped, unless you use C<--no_mce> | ||||||||||||||||||||||||||||||||||||||||||
| 179 | (making it single-thread only - see why below). | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | =item * C<Astro> : Calculates precession between random epochs and finds the | ||||||||||||||||||||||||||||||||||||||||||
| 184 | constellation for random equatorial coordinates using L<Astro::Coord::Precession> | ||||||||||||||||||||||||||||||||||||||||||
| 185 | and L<Astro::Coord::Constellations> respectively. | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | =item * C<BioPerl Codons> : Counts codons on a sample bacterial sequence. Requires | ||||||||||||||||||||||||||||||||||||||||||
| 188 | L<BioPerl> to be installed. | ||||||||||||||||||||||||||||||||||||||||||
| 189 | This test does not scale well on multiple threads, so is disabled by default (use | ||||||||||||||||||||||||||||||||||||||||||
| 190 | C<--bio_codons>) option. Requires data fetched using the C<--setup> option. | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | =item * C<BioPerl Monomers> : Counts monomers on 500 sample bacterial sequences using | ||||||||||||||||||||||||||||||||||||||||||
| 193 | L<BioPerl> (which needs to be installed). Requires data fetched using the C<--setup> | ||||||||||||||||||||||||||||||||||||||||||
| 194 | option. | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | =item * C<CSS::Inliner> : Inlines CSS on 2 sample wiki pages using L<CSS::Inliner>. | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | =item * C<Crypt::JWT> : Creates large JSON Web Tokens with RSA and EC crypto keys | ||||||||||||||||||||||||||||||||||||||||||
| 199 | using L<Crypt::JWT>. | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | =item * C<DateTime> : Creates and manipulates L<DateTime> objects. | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | =item * C<DBI/SQL> : Creates a mock L<DBI> connection (using L<DBD::Mock>) and passes | ||||||||||||||||||||||||||||||||||||||||||
| 204 | it insert/select statements using L<SQL::Inserter> and L<SQL::Abstract::Classic>. | ||||||||||||||||||||||||||||||||||||||||||
| 205 | The latter is quite slow at creating the statements, but it is widely used. | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | =item * C<Digest> : Creates MD5, SH1 and SHA-512 digests of a large string. | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | =item * C<Encode> : Encodes/decodes large strings from/to UTF-8/16, cp-1252. | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | =item * C<HTML::FormatText> : Converts HTML to text for 2 sample wiki pages using | ||||||||||||||||||||||||||||||||||||||||||
| 212 | L<HTML::FormatText>. | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | =item * C<Imager> : Loads a sample image and performs edits/manipulations with | ||||||||||||||||||||||||||||||||||||||||||
| 215 | L<Imager>, including filters like gaussian, unsharp mask, mandelbrot. | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | =item * C<JSON::XS> : Encodes/decodes random data structures to/from JSON using | ||||||||||||||||||||||||||||||||||||||||||
| 218 | L<JSON::XS>. | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | =item * C<Math::DCT> : Does 8x8, 18x18 and 32x32 DCT transforms with L<Math::DCT>. | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | =item * C<Math::MatrixReal> : Performs various manipulations on L<Math::MatrixReal> | ||||||||||||||||||||||||||||||||||||||||||
| 223 | matrices. | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | =item * C<Moose> : Creates L<Moose> objects. | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | =item * C<Moose prove> : Runs 110 tests from the Moose 2.2201 test suite. The least | ||||||||||||||||||||||||||||||||||||||||||
| 228 | CPU-intensive test (which is why there is the option C<--no_prove> to disable it), | ||||||||||||||||||||||||||||||||||||||||||
| 229 | most of the time will be spent loading the interpreter and the Moose module for each | ||||||||||||||||||||||||||||||||||||||||||
| 230 | test, which is behaviour representative of how a Perl test suite runs by default. | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | =item * C<Primes> : Calculates all primes up to 7.5 million. Small number with | ||||||||||||||||||||||||||||||||||||||||||
| 233 | repeat was chosen to keep low memory (this is a pure Perl function no Math libraries). | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | =item * C<Regex/Subst> : Concatenates 3 wiki pages into a byte string then matches | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 3 typical regexes (for names, emails, URIs), replaces html tags with their contents | ||||||||||||||||||||||||||||||||||||||||||
| 237 | (starting with the innermost) and does calls subst a few times. | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | =item * C<Regex/Subst utf8> : Exactly the same as C<Regex/Subst>, but reads into | ||||||||||||||||||||||||||||||||||||||||||
| 240 | a utf8 string. Perl version can make a big difference, as Unicode behaviour has | ||||||||||||||||||||||||||||||||||||||||||
| 241 | changed (old Perl versions are faster but less strict in general). | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | =item * C<Text::Levenshtein> : The edit distance for strings of various lengths (up | ||||||||||||||||||||||||||||||||||||||||||
| 244 | to 2500) are calculated using L<Text::Levenshtein::XS> and L<Text::Levenshtein::Damerau::XS>. | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | =item * C<Time::Piece> : Creates and manipulates/converts Time::Piece objects. It | ||||||||||||||||||||||||||||||||||||||||||
| 247 | is disabled by default on MacOS (unless C<--no_mce> is specified), as it runs | ||||||||||||||||||||||||||||||||||||||||||
| 248 | extremely slow when forked on this platform. In general you may want to skip this | ||||||||||||||||||||||||||||||||||||||||||
| 249 | benchmark (C<--skip_timep>) if you are comparing different OS platforms. | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | =head1 EXPORTED FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | You will normally not use the Benchmark::DKbench module itself, but here are the | ||||||||||||||||||||||||||||||||||||||||||
| 256 | exported functions that the C<dkbench> script uses for reference: | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | =head2 C<system_identity> | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | my $cores = system_identity(); | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | Prints out software/hardware configuration and returns then number of cores detected. | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | =head2 C<suite_run> | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | my %stats = suite_run(\%options); | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | Runs the benchmark suite given the C<%options> and prints results. Returns a hash | ||||||||||||||||||||||||||||||||||||||||||
| 269 | with run stats. | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | =head2 C<calc_scalability> | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | calc_scalability(\%options, \%stat_single, \%stat_multi); | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | Given the C<%stat_single> results of a single-threaded C<suite_run> and C<%stat_multi> | ||||||||||||||||||||||||||||||||||||||||||
| 276 | results of a multi-threaded run, will calculate and print the multi-thread scalability. | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | =head1 NOTES | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | The benchmark suite was created to compare the performance of various cloud offerings. | ||||||||||||||||||||||||||||||||||||||||||
| 281 | You can see the L<original perl blog post|http://blogs.perl.org/users/dimitrios_kechagias/2022/03/cloud-provider-performance-comparison-gcp-aws-azure-perl.html> | ||||||||||||||||||||||||||||||||||||||||||
| 282 | as well as the L<2023 follow-up|https://dev.to/dkechag/cloud-vm-performance-value-comparison-2023-perl-more-1kpp>. | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | The benchmarks for the first version were more tuned to what I would expect to run | ||||||||||||||||||||||||||||||||||||||||||
| 285 | on the servers I was testing, in order to choose the optimal types for the company | ||||||||||||||||||||||||||||||||||||||||||
| 286 | I was working for. The second version has expanded a bit over that, and is friendlier | ||||||||||||||||||||||||||||||||||||||||||
| 287 | to use. | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | Althought this benchmark is in general a good indicator of general CPU performance | ||||||||||||||||||||||||||||||||||||||||||
| 290 | and can be customized to your needs, no benchmark is as good as running your own | ||||||||||||||||||||||||||||||||||||||||||
| 291 | actual workload. | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | =head2 SCORES | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | Some sample DKbench score results from various systems for comparison (all on | ||||||||||||||||||||||||||||||||||||||||||
| 296 | reference setup with Perl 5.36.0): | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | CPU Cores/HT Single Multi Scalability | ||||||||||||||||||||||||||||||||||||||||||
| 299 | Intel i7-4750HQ @ 2.0 (MacOS) 4/8 612 2332 46.9% | ||||||||||||||||||||||||||||||||||||||||||
| 300 | AMD Ryzen 5 PRO 4650U @ 2.1 (WSL) 6/12 906 4166 38.2% | ||||||||||||||||||||||||||||||||||||||||||
| 301 | Apple M1 Pro @ 3.2 (MacOS) 10/10 1283 10026 78.8% | ||||||||||||||||||||||||||||||||||||||||||
| 302 | Apple M2 Pro @ 3.5 (MacOS) 12/12 1415 12394 73.1% | ||||||||||||||||||||||||||||||||||||||||||
| 303 | Ampere Altra @ 3.0 (Linux) 48/48 708 32718 97.7% | ||||||||||||||||||||||||||||||||||||||||||
| 304 | Intel Xeon Platinum 8481C @ 2.7 (Linux) 88/176 1000 86055 48.9% | ||||||||||||||||||||||||||||||||||||||||||
| 305 | AMD EPYC Milan 7B13 @ 2.45 (Linux) 112/224 956 104536 49.3% | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | Dimitrios Kechagias, C<< <dkechag at cpan.org> >> | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | Please report any bugs or feature requests either on L<GitHub|https://github.com/dkechag/Benchmark-DKbench> (preferred), or on RT (via the email | ||||||||||||||||||||||||||||||||||||||||||
| 314 | C<bug-Benchmark-DKbench at rt.cpan.org> or L<web interface|https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Benchmark-DKbench>). | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | =head1 GIT | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | L<https://github.com/dkechag/Benchmark-DKbench> | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | This software is copyright (c) 2021-2023 by Dimitrios Kechagias. | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 327 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | sub benchmark_list { | ||||||||||||||||||||||||||||||||||||||||||
| 332 | return { # idx : 0 = result, 1 = ref time, 2 = func, 3 = quick test, 4 = normal test, 5 = ver | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 2 | ▶ | 'Astro' => ['e71c7ae08f16fe26aea7cfdb72785873', 5.674, \&bench_astro, 20000, 80000], | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
benchmark_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 'BioPerl Codons' => ['97c443c099886ca60e99f7ab9df689b5', 8.752, \&bench_bioperl_codons, 3, 5, 1], | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 'BioPerl Monomers' => ['d29ed0a5c205c803c112be1338d1f060', 5.241, \&bench_bioperl_mono, 6, 20], | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 'Crypt::JWT' => ['d41d8cd98f00b204e9800998ecf8427e', 6.451, \&bench_jwt, 250, 900], | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 'CSS::Inliner' => ['82c1b6de9ca0500a48f8a8df0998df3c', 4.603, \&bench_css, 2, 5], | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 'DBI/SQL' => ['2b8252daad9568a5b39038c696df4be3', 5.700, \&bench_dbi, 5000, 15000, 2.1], | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 'DateTime' => ['b08d2eeb994083b7422f6c9d86fed2c6', 6.198, \&bench_datetime, 5000, 15000], | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 'Digest' => ['4b69f6cf0f53cbf6c3444f2f767dd21d', 4.513, \&bench_digest, 50, 250], | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 'Encode' => ['PASS 1025', 5.725, \&bench_encode, 40, 120], | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 'HTML::FormatText' => ['8c2589f0a5276252805e11301fc2ab56', 4.756, \&bench_formattext, 4, 10], | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 'Imager' => ['8829cb3703e884054eb025496f336c63', 6.792, \&bench_imager, 4, 16], | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 'JSON::XS' => ['PASS', 5.388, \&bench_json, 600, 2200], | ||||||||||||||||||||||||||||||||||||||||||
| 345 | 'Math::DCT' => ['766e3bfd7a2276f452bb3d1bd21939bc', 7.147, \&bench_dct, 25000, 100_000], | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 'Math::MatrixReal' => ['4606231b1309fb21ae1223fa0043fd76', 4.293, \&bench_matrixreal, 200, 650], | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 'Moose' => ['d1cb92c513f6378506dfa11f694cffac', 4.968, \&bench_moose, 10_000, 30_000], | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 'Moose prove' => ['PASS', 7.974, \&bench_moose_prv, 0.5, 1], | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 'Primes' => ['4266f70a7a9efb3484cf5d98eba32244', 3.680, \&bench_primes_m, 2, 5], | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 'Regex/Subst' => ['30ce365b25f3d597578b3bdb14aa3f57', 4.652, \&bench_regex_asc, 8, 24], | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 'Regex/Subst utf8' => ['857eb4e63a4d174ca4a16fe678f7626f', 5.703, \&bench_regex_utf8, 3, 10], | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 'Text::Levenshtein' => ['2948a300ed9131fa0ce82bb5eabb8ded', 5.539, \&bench_textlevenshtein, 7, 25, 2.1], | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 'Time::Piece' => ['2d4b149fe7f873a27109fc376d69211b', 5.907, \&bench_timepiece, 75_000, 275_000], | ||||||||||||||||||||||||||||||||||||||||||
| 354 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | sub system_identity { | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | ▶ | my ($physical, $cores, $ncpu) = | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
system_identity: called CC=18 SCAR=37.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | $^O =~ /bsd|darwin|dragonfly/ ? bsd_cpu() : linux_cpu(); | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 1 | ▶ | $ncpu ||= MCE::Util::get_ncpu() || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition20%1/5
$ncpu ||= MCE::Util::get_ncpu() || 1
MCE::Util::get_ncpu() || 1
MC/DC0%0/2
$ncpu ||= MCE::Util::get_ncpu() || 1
$ncpu
MCE::Util::get_ncpu()
Truth table33%1/3
A ||= B
A= $ncpuB= MCE::Util::get_ncpu()
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | ▶ | local $^O = 'linux' if $^O =~ /android/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 1 | my $info = System::Info->sysinfo_hash; | |||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | ▶ | my $osn = $info->{distro} || $info->{os} || $^O; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$info->{'distro'} || $info->{'os'} || $^O
$info->{"distro"} or $info->{"os"}
MC/DC0%0/3
$info->{'distro'} || $info->{'os'} || $^O
$info->{"distro"}
$info->{"os"}
$^O
Truth table25%1/4
A or B || C
A= $info->{"distro"}B= $info->{"os"}C= $^O
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | my $model = $info->{cpu}; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | ▶ | my $arch = $info->{cpu_type} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$info->{'cpu_type'} || ''
MC/DC0%0/1
$info->{'cpu_type'} || ''
$info->{'cpu_type'}
Truth table50%1/2
A
A= $info->{'cpu_type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | ▶ | $arch = " ($arch)" if $arch; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 1 | ▶ | if ($^O =~ /darwin/ && $model =~ /^Mac|nknown/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$^O =~ /darwin/ and $model =~ /^Mac|nknown/
MC/DC0%0/2
$^O =~ /darwin/ and $model =~ /^Mac|nknown/
$^O =~ /darwin/
$model =~ /^Mac|nknown/
Truth table33%1/3
A and B
A= $^O =~ /darwin/B= $model =~ /^Mac|nknown/
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $brand = `sysctl -a |grep brand`; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | $model = $1 if $brand =~ /brand_string: (.*)/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | $model =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||
| 372 | 1 | $model =~ s/\(R\)//g; | |||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | print "--------------- Software ---------------\nDKbench v$VERSION\n"; | |||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | print "Perl $^V\n"; | |||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | print "OS: $osn\n--------------- Hardware ---------------\n"; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | print "CPU type: $model$arch\n"; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | print "CPUs: $ncpu"; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | my @extra; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | ▶ | push @extra, "$physical Processors" if $physical && $physical > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$physical and $physical > 1
MC/DC0%0/2
$physical and $physical > 1
$physical
$physical > 1
Truth table33%1/3
A and B
A= $physicalB= $physical > 1
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | ▶ | push @extra, "$cores Cores" if $cores; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | ▶ | push @extra, "$ncpu Threads" if $cores && $cores != $ncpu; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$cores and $cores != $ncpu
MC/DC0%0/2
$cores and $cores != $ncpu
$cores
$cores != $ncpu
Truth table33%1/3
A and B
A= $coresB= $cores != $ncpu
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 1 | ▶ | print " (".join(', ', @extra).")" if @extra; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | print "\n".("-"x40)."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | return $ncpu; | |||||||||||||||||||||||||||||||||||||||||
| 386 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | sub bsd_cpu { | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | chomp( my $cpus = `sysctl -n hw.ncpu 2>/dev/null` ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bsd_cpu: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | return unless $cpus; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | chomp( my $cores = `sysctl -n hw.physicalcpu 2>/dev/null` ); | |||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | $cores ||= $cpus; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$cores ||= $cpus
MC/DC0%0/2
$cores ||= $cpus
$cores
$cpus
Truth table0%0/3
A ||= B
A= $coresB= $cpus
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | return (undef, $cores, $cpus); | |||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | sub linux_cpu { | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 1 | ▶ | my (@physical, @cores, $phys, $cpus); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
linux_cpu: called CC=14 SCAR=29.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | ▶ | if ( -f '/proc/cpuinfo' && open my $fh, '<', '/proc/cpuinfo' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-f "/proc/cpuinfo" and open my $fh, "<", "/proc/cpuinfo"
MC/DC0%0/2
-f "/proc/cpuinfo" and open my $fh, "<", "/proc/cpuinfo"
-f "/proc/cpuinfo"
open my $fh, "<", "/proc/cpuinfo"
Truth table33%1/3
A and B
A= -f "/proc/cpuinfo"B= open my $fh, "<", "/proc/cpuinfo"
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 351 | ▶ | $cpus++ if /^processor\s*:/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 351 | ▶ | push @physical, $1 if /^physical id\s*:\s*(\d+)/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 351 | ▶ | push @cores, $1 if /^cpu cores\s*:\s*(\d+)/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | ▶ | return undef, $cores[0], $cpus if !@physical && @cores; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not @physical and @cores
MC/DC0%0/2
not @physical and @cores
not @physical
@cores
Truth table33%1/3
not(A) and B
A= not @physicalB= @cores
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | ▶ | @cores = (0) unless @cores; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | my %hash; | |||||||||||||||||||||||||||||||||||||||||
| 407 | $hash{$physical[$_]} = $_ < scalar(@cores) ? $cores[$_] : $cores[0] | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | ▶ | for 0 .. $#physical; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 1 | ▶ | my $phys = keys %hash || undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
keys %hash || undef
MC/DC0%0/1
keys %hash || undef
keys %hash
Truth table50%1/2
A
A= keys %hash
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | ▶ | my $cores = sum(values %hash) || $cpus; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
&sum(values %hash) || $cpus
MC/DC0%0/2
&sum(values %hash) || $cpus
&sum(values %hash)
$cpus
Truth table33%1/3
A || B
A= &sum(values %hash)B= $cpus
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | return $phys, $cores, $cpus; | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | sub suite_run { | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 2 | ▶ | my $opt = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
suite_run: called CC=9 SCAR=24.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 2 | ▶ | $datadir = $opt->{datapath} if $opt->{datapath}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | ▶ | $opt->{threads} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opt->{"threads"} //= 1
MC/DC0%0/1
$opt->{"threads"} //= 1
$opt->{"threads"}
Truth table50%1/2
A
A= $opt->{"threads"}
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 2 | ▶ | $opt->{repeat} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opt->{"repeat"} //= 1
MC/DC0%0/1
$opt->{"repeat"} //= 1
$opt->{"repeat"}
Truth table50%1/2
A
A= $opt->{"repeat"}
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 2 | ▶ | $opt->{f} = $opt->{time} ? '%.3f' : '%5.0f'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | my %stats = (threads => $opt->{threads}); | |||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | MCE::Loop::init { | ||||||||||||||||||||||||||||||||||||||||||
| 425 | max_workers => $opt->{threads}, | ||||||||||||||||||||||||||||||||||||||||||
| 426 | chunk_size => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 427 | 2 | ▶ | } unless $opt->{no_mce}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 2 | foreach (1..$opt->{iter}) { | |||||||||||||||||||||||||||||||||||||||||
| 430 | 2 | ▶ | print "Iteration $_ of $opt->{iter}...\n" if $opt->{iter} > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 2 | run_iteration($opt, \%stats); | |||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | total_stats($opt, \%stats) if $opt->{iter} > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | return %stats; | |||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | sub calc_scalability { | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | my ($opt, $stats1, $stats2) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calc_scalability: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $benchmarks = benchmark_list(); | |||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $threads = $stats2->{threads}/$stats1->{threads}; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | my $display = $opt->{time} ? 'times' : 'scores'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | $opt->{f} = $opt->{time} ? '%.3f' : '%5.0f'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my (@perf, @scal); | |||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | print "Multi thread Scalability:\n".pad_to("Benchmark",24).pad_to("Multi perf xSingle",24).pad_to("Multi scalability %",24); | |||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my $cnt; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | foreach my $bench (sort keys %$benchmarks) { | |||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | next unless $stats1->{$bench}->{times} && $stats2->{$bench}->{times}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$stats1->{$bench}{"times"} and $stats2->{$bench}{"times"}
MC/DC0%0/2
$stats1->{$bench}{"times"} and $stats2->{$bench}{"times"}
$stats1->{$bench}{"times"}
$stats2->{$bench}{"times"}
Truth table0%0/3
A and B
A= $stats1->{$bench}{"times"}B= $stats2->{$bench}{"times"}
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $cnt++; | |||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my @res1 = min_max_avg($stats1->{$bench}->{times}); | |||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my @res2 = min_max_avg($stats2->{$bench}->{times}); | |||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | push @perf, $res1[2]/$res2[2]*$threads if $res2[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | push @scal, $res1[2]/$res2[2]*100 if $res2[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | print pad_to("$bench:",24).pad_to(sprintf("%.2f",$perf[-1]),24).pad_to(sprintf("%2.0f",$scal[-1]),24)."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | print (("-"x40)."\n"); | |||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my $avg1 = min_max_avg($stats1->{total}->{$display}); | |||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my $avg2 = min_max_avg($stats2->{total}->{$display}); | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | print "DKbench summary ($cnt benchmarks, $stats2->{threads} threads):\n"; | |||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | print pad_to("Single:").sprintf($opt->{f}, $avg1)."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | print pad_to("Multi:").sprintf($opt->{f}, $avg2)."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my @newperf = Benchmark::DKbench::drop_outliers(\@perf, -1); | |||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my @newscal = Benchmark::DKbench::drop_outliers(\@scal, -1); | |||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | @perf = min_max_avg(\@newperf); | |||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | @scal = min_max_avg(\@newscal); | |||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | print pad_to("Multi/Single perf:").sprintf("%.2fx\t(%.2f - %.2f)", $perf[2], $perf[0], $perf[1])."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | print pad_to("Multi scalability:").sprintf("%2.1f%% \t(%.0f%% - %.0f%%)", $scal[2], $scal[0], $scal[1])."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | sub run_iteration { | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 2 | ▶ | my ($opt, $stats) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_iteration: called CC=27 SCAR=38.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | 2 | my $benchmarks = benchmark_list(); | |||||||||||||||||||||||||||||||||||||||||
| 475 | 2 | ▶ | my $title = $opt->{time} ? 'Time (sec)' : 'Score'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 2 | print pad_to("Benchmark").pad_to($title); | |||||||||||||||||||||||||||||||||||||||||
| 477 | 2 | ▶ | print "Pass/Fail" unless $opt->{time}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 2 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 479 | 2 | my ($total_score, $total_time, $i) = (0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 480 | 2 | foreach my $bench (sort keys %$benchmarks) { | |||||||||||||||||||||||||||||||||||||||||
| 481 | 26 | ▶ | next if $opt->{skip_bio} && $bench =~ /Monomers/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opt->{"skip_bio"} and $bench =~ /Monomers/
MC/DC100%2/2
$opt->{"skip_bio"} and $bench =~ /Monomers/
$opt->{"skip_bio"}
$bench =~ /Monomers/
Truth table100%3/3
A and B
A= $opt->{"skip_bio"}B= $bench =~ /Monomers/
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 25 | ▶ | next if $opt->{skip_prove} && $bench =~ /prove/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt->{"skip_prove"} and $bench =~ /prove/
MC/DC0%0/2
$opt->{"skip_prove"} and $bench =~ /prove/
$opt->{"skip_prove"}
$bench =~ /prove/
Truth table33%1/3
A and B
A= $opt->{"skip_prove"}B= $bench =~ /prove/
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | 25 | ▶ | next if !$opt->{bio_codons} && $bench =~ /Codons/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $opt->{"bio_codons"} and $bench =~ /Codons/
MC/DC50%1/2
not $opt->{"bio_codons"} and $bench =~ /Codons/
not $opt->{"bio_codons"}
$bench =~ /Codons/
Truth table66%2/3
not(A) and B
A= not $opt->{"bio_codons"}B= $bench =~ /Codons/
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 23 | ▶ | next if $opt->{skip_timep} && $bench =~ /Time::Piece/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt->{"skip_timep"} and $bench =~ /Time::Piece/
MC/DC0%0/2
$opt->{"skip_timep"} and $bench =~ /Time::Piece/
$opt->{"skip_timep"}
$bench =~ /Time::Piece/
Truth table33%1/3
A and B
A= $opt->{"skip_timep"}B= $bench =~ /Time::Piece/
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 23 | ▶ | next if $opt->{ver} && $benchmarks->{$bench}->[5] && $opt->{ver} < $benchmarks->{$bench}->[5]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$opt->{"ver"} and $benchmarks->{$bench}[5] and $opt->{"ver"} < $benchmarks->{$bench}[5]
$opt->{"ver"} and $benchmarks->{$bench}[5]
MC/DC0%0/3
$opt->{"ver"} and $benchmarks->{$bench}[5] and $opt->{"ver"} < $benchmarks->{$bench}[5]
$opt->{"ver"}
$benchmarks->{$bench}[5]
$opt->{"ver"} < $benchmarks->{$bench}[5]
Truth table50%2/4
A and B and C
A= $opt->{"ver"}B= $benchmarks->{$bench}[5]C= $opt->{"ver"} < $benchmarks->{$bench}[5]
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 23 | ▶ | next if $opt->{exclude} && $bench =~ /$opt->{exclude}/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt->{"exclude"} and $bench =~ /$opt->{"exclude"}/
MC/DC50%1/2
$opt->{"exclude"} and $bench =~ /$opt->{"exclude"}/
$opt->{"exclude"}
$bench =~ /$opt->{"exclude"}/
Truth table66%2/3
A and B
A= $opt->{"exclude"}B= $bench =~ /$opt->{"exclude"}/
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 21 | ▶ | next if $opt->{include} && $bench !~ /$opt->{include}/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt->{"include"} and not $bench =~ /$opt->{"include"}/
MC/DC50%1/2
$opt->{"include"} and not $bench =~ /$opt->{"include"}/
$opt->{"include"}
not $bench =~ /$opt->{"include"}/
Truth table66%2/3
A and not(B)
A= $opt->{"include"}B= not $bench =~ /$opt->{"include"}/
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 3 | ▶ | if ($bench =~ /Bio/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | require Bio::SeqIO; | |||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | require Bio::Tools::SeqStats; | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | 3 | my ($time, $res) = mce_bench_run($opt, $benchmarks->{$bench}); | |||||||||||||||||||||||||||||||||||||||||
| 493 | 2 | ▶ | my $score = int(1000*$opt->{threads}*$benchmarks->{$bench}->[1]/($time || 1)+0.5); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$time || 1
MC/DC0%0/1
$time || 1
$time
Truth table50%1/2
A
A= $time
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | 2 | $total_score += $score; | |||||||||||||||||||||||||||||||||||||||||
| 495 | 2 | $total_time += $time; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 2 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 497 | 2 | push @{$stats->{$bench}->{times}}, $time; | |||||||||||||||||||||||||||||||||||||||||
| 498 | 2 | push @{$stats->{$bench}->{scores}}, $score; | |||||||||||||||||||||||||||||||||||||||||
| 499 | 2 | ▶ | my $d = $stats->{$bench}->{$opt->{time} ? 'times' : 'scores'}->[-1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 2 | ▶ | $stats->{$bench}->{fail}++ if $res ne 'Pass'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | 2 | print pad_to("$bench:").pad_to(sprintf($opt->{f}, $d)); | |||||||||||||||||||||||||||||||||||||||||
| 502 | 2 | ▶ | print "$res" unless $opt->{time}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 2 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | ▶ | sleep $opt->{sleep} if $opt->{sleep}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||
| 506 | 1 | ▶ | die "No tests to run\n" unless $i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my $s = int($total_score/$i+0.5); | |||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | print pad_to("Overall $title: ").sprintf($opt->{f}."\n", $opt->{time} ? $total_time : $s); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | push @{$stats->{total}->{times}}, $total_time; | |||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | push @{$stats->{total}->{scores}}, $s; | |||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | sub mce_bench_run { | ||||||||||||||||||||||||||||||||||||||||||
| 514 | 3 | ▶ | my $opt = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mce_bench_run: called CC=6 SCAR=30.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 3 | my $benchmark = shift; | |||||||||||||||||||||||||||||||||||||||||
| 516 | 3 | ▶ | $benchmark->[3] = $benchmark->[4] unless $opt->{quick}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 3 | ▶ | return bench_run($benchmark) if $opt->{no_mce}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | my @stats = mce_loop { | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | my ($mce, $chunk_ref, $chunk_id) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | for (@{$chunk_ref}) { | |||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my ($time, $res) = bench_run($benchmark); | |||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | MCE->gather([$time, $res]); | |||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | (1 .. $opt->{threads} * $opt->{repeat}); | |||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my ($res, $time) = ('Pass', 0); | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | foreach (@stats) { | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | $time += $_->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | $res = $_->[1] if $_->[1] ne 'Pass'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | return $time/($opt->{threads}*$opt->{repeat} || 1), $res; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opt->{'threads'} * $opt->{'repeat'} || 1
MC/DC0%0/1
$opt->{'threads'} * $opt->{'repeat'} || 1
$opt->{'threads'} * $opt->{'repeat'}
Truth table0%0/2
A
A= $opt->{'threads'} * $opt->{'repeat'}
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | sub bench_run { | ||||||||||||||||||||||||||||||||||||||||||
| 538 | 4 | ▶ | my ($benchmark, $srand) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_run: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | 4 | ▶ | $srand //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$srand //= 1
MC/DC100%1/1
$srand //= 1
$srand
Truth table100%2/2
A
A= $srand
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 4 | srand($srand); # For repeatability | |||||||||||||||||||||||||||||||||||||||||
| 541 | 4 | my $t0 = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||||||||||
| 542 | 4 | my $out = $benchmark->[2]->($benchmark->[3]); | |||||||||||||||||||||||||||||||||||||||||
| 543 | 2 | my $time = sprintf("%.3f", Time::HiRes::time()-$t0); | |||||||||||||||||||||||||||||||||||||||||
| 544 | 2 | ▶ | my $r = $out eq $benchmark->[0] ? 'Pass' : "Fail ($out)"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 2 | return $time, $r; | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | sub bench_astro { | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 1 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_astro: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 1 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 551 | my $precessed = precess([rand(24), rand(180)-90], rand(200)+1900, rand(200)+1900) | ||||||||||||||||||||||||||||||||||||||||||
| 552 | 1 | for (1..$iter*10); | |||||||||||||||||||||||||||||||||||||||||
| 553 | 1 | my $constellation_abbrev; | |||||||||||||||||||||||||||||||||||||||||
| 554 | $d->add(constellation_for_eq(rand(24), rand(180)-90, rand(200)+1900)) | ||||||||||||||||||||||||||||||||||||||||||
| 555 | 1 | for (1..$iter); | |||||||||||||||||||||||||||||||||||||||||
| 556 | 1 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | sub bench_bioperl_codons { | ||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | my $skip = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_bioperl_codons: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my $iter = shift; | |||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $file = catfile($datadir, "gbbct5.seq"); | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | foreach (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my $in = Bio::SeqIO->new(-file => $file, -format => "genbank"); | |||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | $in->next_seq for (1..$skip); | |||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $seq = $in->next_seq; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my $seq_stats = Bio::Tools::SeqStats->new($seq); | |||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my $codon_ref = $seq_stats->count_codons(); | |||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $d->add($_, $codon_ref->{$_}) for sort keys %$codon_ref; | |||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | sub bench_bioperl_mono { | ||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_bioperl_mono: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my $file = catfile($datadir, "gbbct5.seq"); | |||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my $in = Bio::SeqIO->new(-file => $file, -format => "genbank"); | |||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my $builder = $in->sequence_builder(); | |||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $builder->want_none(); | |||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | $builder->add_wanted_slot('display_id','seq'); | |||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | for (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | my $seq = $in->next_seq; | |||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $seq_stats = Bio::Tools::SeqStats->new($seq); | |||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my $weight = $seq_stats->get_mol_wt(); | |||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $d->add(int($weight->[0])); | |||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my $monomer_ref = $seq_stats->count_monomers(); | |||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | $d->add($_, $monomer_ref->{$_}) for sort keys %$monomer_ref; | |||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | sub bench_css { | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 1 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_css: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 1 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | my $file; | |||||||||||||||||||||||||||||||||||||||||
| 598 | my $html; | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 1 | for (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 600 | 2 | my $inliner = new CSS::Inliner(); | |||||||||||||||||||||||||||||||||||||||||
| 601 | 2 | my $i = $_ % 2 + 1; | |||||||||||||||||||||||||||||||||||||||||
| 602 | 2 | $file = catfile($datadir, "wiki$i.html"); | |||||||||||||||||||||||||||||||||||||||||
| 603 | 2 | $inliner->read_file({ filename => $file }); | |||||||||||||||||||||||||||||||||||||||||
| 604 | 2 | $html = $inliner->inlinify(); | |||||||||||||||||||||||||||||||||||||||||
| 605 | 2 | $d->add(Encode::encode_utf8($html)); | |||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||
| 607 | 1 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | sub bench_datetime { | ||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_datetime: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | my @tz = map {DateTime::TimeZone->new( name => $_ )} qw(UTC Europe/London America/New_York); | |||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | my $str; | |||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | for (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | my $dt = DateTime->now(); | |||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my $dt1 = DateTime->from_epoch( | |||||||||||||||||||||||||||||||||||||||||
| 619 | epoch => 946684800 + rand(100000000), | ||||||||||||||||||||||||||||||||||||||||||
| 620 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | my $dt2 = DateTime->from_epoch( | |||||||||||||||||||||||||||||||||||||||||
| 622 | epoch => 946684800 + rand(100000000), | ||||||||||||||||||||||||||||||||||||||||||
| 623 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | $str = $dt2->strftime('%FT%T')."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | $d->add($str); | |||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | eval {$dt2->set_time_zone($tz[int(rand(3))])}; | |||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my $dur = $dt2->subtract_datetime($dt1); | |||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | eval {$dt2->add_duration($dur)}; | |||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | eval {$dt2->subtract(days => int(rand(1000)+1))}; | |||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | $dt->week; | |||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | $dt->epoch; | |||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | $d->add($dt2->strftime('%FT%T')); | |||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | eval {$dt2->set( year => int(rand(2030)))}; | |||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | $d->add($dt2->ymd('/')); | |||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | sub bench_dbi { | ||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_dbi: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | my $dbh = DBI->connect( 'DBI:Mock:', '', '' ); | |||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | my ($data, $cols) = _db_data(); | |||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | foreach (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | my $inserter = SQL::Inserter->new( | |||||||||||||||||||||||||||||||||||||||||
| 647 | dbh => $dbh, | ||||||||||||||||||||||||||||||||||||||||||
| 648 | table => 'table', | ||||||||||||||||||||||||||||||||||||||||||
| 649 | cols => $cols, | ||||||||||||||||||||||||||||||||||||||||||
| 650 | buffer => 2 | ||||||||||||||||||||||||||||||||||||||||||
| 651 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | $inserter->insert($data->[int(rand(20))]) for 1..2; | |||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | $d->add($dbh->last_insert_id); | |||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | my $sql = SQL::Abstract::Classic->new(); | |||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my ($stmt, @bind) = $sql->insert('table', $data->[int(rand(20))]); | |||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | $d->add($dbh->quote($stmt)); | |||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ($stmt, @bind) = $sql->select('table', $cols->[int(rand(20))], [map {_rand_where()} 1..int(rand(3)+1)]); | |||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | $d->add($dbh->quote($stmt._random_str(5))); | |||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my $dbh2 = DBI->connect( 'DBI:Mock:', '', '' ); | |||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | sub bench_dct { | ||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_dct: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $d->add(bench_dct_sz(@$_)) foreach [$iter, 32], [$iter, 18], [$iter*8,8]; | |||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | sub bench_dct_sz { | ||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_dct_sz: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | my $sz = shift; | |||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | my @arrays; | |||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | push @arrays, [map { rand(256) } ( 1..$sz*$sz )] foreach 1..10; | |||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | foreach (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my $dct = dct2d($arrays[$iter % 10], $sz); | |||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | $d->add($dct->[0]) if $_ % 10 == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | sub bench_digest { | ||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_digest: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | my $str = _read_wiki_files(); | |||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | my $hex; | |||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | foreach (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my $d2 = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | $d2->add($str); | |||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | $hex = $d2->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $d->add($hex); | |||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $d2 = Digest->new("SHA-512"); | |||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $d2->add($str); | |||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $hex = $d2->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $d->add($hex); | |||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | $d2 = Digest->new("SHA-1"); | |||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | $d2->add($str); | |||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | $hex = $d2->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | $d->add($hex); | |||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | sub bench_encode { | ||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_encode: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | my $str = _read_wiki_files('utf8'); | |||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | my $UTF8 = Encode::find_encoding('UTF-8'); | |||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | my $UTF16 = Encode::find_encoding('UTF-16'); | |||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | our $cp1252 = Encode::find_encoding('cp-1252'); | |||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my $res = 'PASS'; | |||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | my $unenc = 0; | |||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | foreach (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my $bytes = encode_utf8($str); | |||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | $res = 'Fail' unless length($bytes) > length($str); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | my $cp = decode_utf8($bytes); | |||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | my $enc = rand(1) > 0.25 ? $UTF8 : $UTF16; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | $bytes = $enc->encode($cp); | |||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | $cp = $enc->decode($bytes); | |||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | $res = 'Fail' unless $cp eq $str; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | my $str2 = $cp1252->encode($cp); | |||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | $enc->encode($cp1252->decode($str2)); | |||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | $unenc = () = $str2 =~ /\?/g; # Non-encodable | |||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | return "$res $unenc"; | |||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | sub bench_imager { | ||||||||||||||||||||||||||||||||||||||||||
| 732 | 1 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_imager: called CC=4 SCAR=26.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | 1 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||
| 735 | 1 | my $data; | |||||||||||||||||||||||||||||||||||||||||
| 736 | 1 | ▶ | open (my $fh, '<:raw', catfile($datadir,'M31.bmp')) or die $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | read($fh, $data, -s $fh); | |||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | foreach (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | my $img = Imager->new(data=>$data, type=>'bmp') or die Imager->errstr(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | my $thumb = $img->scale(scalefactor=>.3); | |||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | my $newimg = $img->scale(scalefactor=>1.15); | |||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | $newimg->filter(type=>'autolevels'); | |||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | $newimg->filter(type=>"gaussian", stddev=>0.5); | |||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | $newimg->paste(left=>40,top=>20,img=>$thumb); | |||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | $newimg->rubthrough(src=>$thumb,tx=>30, ty=>50); | |||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | $newimg->compose(src => $thumb, tx => 30, ty => 20, combine => 'color'); | |||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | $newimg->flip(dir=>"h"); | |||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | $newimg->flip(dir=>"vh"); | |||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | $d->add(scalar(Image::PHash->new($newimg)->pHash)); | |||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | $newimg = $img->crop(left=>50, right=>100, top=>10, bottom=>100); | |||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | $newimg = $img->crop(left=>50, top=>10, width=>50, height=>90); | |||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | $newimg = $img->copy(); | |||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | $newimg->filter(type=>"unsharpmask", stddev=>1, scale=>0.5); | |||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | $newimg = $img->rotate(degrees=>20); | |||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | $newimg->filter(type=>"contrast", intensity=>1.4); | |||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | $newimg = $img->convert(matrix => [[0, 1, 0], [1, 0, 0], [0, 0, 1]]); | |||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | $newimg = $img->convert(preset=>'grey'); | |||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | $d->add(scalar(Image::PHash->new($newimg)->pHash)); | |||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $img->filter(type=>'mandelbrot'); | |||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | sub bench_json { | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_json: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | my $res = 'PASS'; | |||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | for (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | my $len = int(rand(40)) + 1; | |||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | my $obj = rand_hash($len); | |||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | my $str = encode_json($obj); | |||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | foreach (1..100) { | |||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | $obj = decode_json($str); | |||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | $str = encode_json($obj); | |||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | my $obj2 = decode_json($str); | |||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | ▶ | $res = 'FAIL' unless compare_obj($obj, $obj2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||
| 783 | sub bench_jwt { | ||||||||||||||||||||||||||||||||||||||||||
| 784 | 1 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_jwt: called CC=4 SCAR=18.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 785 | 1 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 786 | 1 | my $data = _random_str(5000); | |||||||||||||||||||||||||||||||||||||||||
| 787 | 1 | my $rsa ='-----BEGIN PRIVATE KEY----- | |||||||||||||||||||||||||||||||||||||||||
| 788 | MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqPfgaTEWEP3S9w0t | ||||||||||||||||||||||||||||||||||||||||||
| 789 | gsicURfo+nLW09/0KfOPinhYZ4ouzU+3xC4pSlEp8Ut9FgL0AgqNslNaK34Kq+NZ | ||||||||||||||||||||||||||||||||||||||||||
| 790 | jO9DAQIDAQABAkAgkuLEHLaqkWhLgNKagSajeobLS3rPT0Agm0f7k55FXVt743hw | ||||||||||||||||||||||||||||||||||||||||||
| 791 | Ngkp98bMNrzy9AQ1mJGbQZGrpr4c8ZAx3aRNAiEAoxK/MgGeeLui385KJ7ZOYktj | ||||||||||||||||||||||||||||||||||||||||||
| 792 | hLBNAB69fKwTZFsUNh0CIQEJQRpFCcydunv2bENcN/oBTRw39E8GNv2pIcNxZkcb | ||||||||||||||||||||||||||||||||||||||||||
| 793 | NQIgbYSzn3Py6AasNj6nEtCfB+i1p3F35TK/87DlPSrmAgkCIQDJLhFoj1gbwRbH | ||||||||||||||||||||||||||||||||||||||||||
| 794 | /bDRPrtlRUDDx44wHoEhSDRdy77eiQIgE6z/k6I+ChN1LLttwX0galITxmAYrOBh | ||||||||||||||||||||||||||||||||||||||||||
| 795 | BVl433tgTTQ= | ||||||||||||||||||||||||||||||||||||||||||
| 796 | -----END PRIVATE KEY-----'; | ||||||||||||||||||||||||||||||||||||||||||
| 797 | 1 | my $key = '-----BEGIN PRIVATE KEY----- | |||||||||||||||||||||||||||||||||||||||||
| 798 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgYirTZSx+5O8Y6tlG | ||||||||||||||||||||||||||||||||||||||||||
| 799 | cka6W6btJiocdrdolfcukSoTEk+hRANCAAQkvPNu7Pa1GcsWU4v7ptNfqCJVq8Cx | ||||||||||||||||||||||||||||||||||||||||||
| 800 | zo0MUVPQgwJ3aJtNM1QMOQUayCrRwfklg+D/rFSUwEUqtZh7fJDiFqz3 | ||||||||||||||||||||||||||||||||||||||||||
| 801 | -----END PRIVATE KEY-----'; | ||||||||||||||||||||||||||||||||||||||||||
| 802 | 1 | foreach (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 803 | 1 | my $extra = _random_str(100); | |||||||||||||||||||||||||||||||||||||||||
| 804 | 1 | my $data_in = $data.$extra; | |||||||||||||||||||||||||||||||||||||||||
| 805 | 1 | my $token = encode_jwt( | |||||||||||||||||||||||||||||||||||||||||
| 806 | payload => $data_in, | ||||||||||||||||||||||||||||||||||||||||||
| 807 | alg => 'ES256', | ||||||||||||||||||||||||||||||||||||||||||
| 808 | key => \$key, | ||||||||||||||||||||||||||||||||||||||||||
| 809 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | my $data_out = _decode_jwt2(token=>$token, key=>\$key); | |||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | $d->add($token) if $data_in eq $data_out.$extra; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | $token = encode_jwt( | |||||||||||||||||||||||||||||||||||||||||
| 815 | payload => $data_in, | ||||||||||||||||||||||||||||||||||||||||||
| 816 | alg => 'RS256', | ||||||||||||||||||||||||||||||||||||||||||
| 817 | key => \$rsa, | ||||||||||||||||||||||||||||||||||||||||||
| 818 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | $data_out = _decode_jwt2(token=>$token, key=>\$rsa); | |||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | $d->add($token) if $data_in eq $data_out.$extra; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||
| 826 | sub bench_formattext { | ||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_formattext: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | my $file; | |||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | for (0..$iter-1) { | |||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my $i = $_ % 2; | |||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | $file = catfile($datadir, "wiki$i.html"); | |||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | my $tree = HTML::TreeBuilder->new->parse_file($file); | |||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | my $formatter = HTML::FormatText->new(); | |||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | my $text = $formatter->format($tree); | |||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | $formatter = HTML::FormatText->new(leftmargin => 0, rightmargin => 30); | |||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | $d->add(Encode::encode_utf8($formatter->format($tree))); | |||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | sub bench_matrixreal { | ||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_matrixreal: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | my $smatrix = Math::MatrixReal->new_random(13); | |||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | my $matrix = Math::MatrixReal->new_random(20); | |||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | my $bmatrix = Math::MatrixReal->new_random(72); | |||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | for (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my $r = rand(10); | |||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | my $m1 = $r*$bmatrix; | |||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | my $m2 = $bmatrix*$r; | |||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | my $m3 = $bmatrix->multiply_scalar($bmatrix,$r); | |||||||||||||||||||||||||||||||||||||||||
| 854 | # Should be zero | ||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | $d->add($m1->element(1, 1) + $m2->element(1, 1) - 2 * $bmatrix->element(1, 1)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 856 | if $_ % 10 == 1; | ||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | my $m = $matrix->det; | |||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | ▶ | $d->add($m) if $_ % 10 == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | $m =$matrix->decompose_LR->det_LR; | |||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | $d->add($m) if $_ % 10 == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | $m1 = $matrix ** 2; | |||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | $m2 = $matrix * $matrix; | |||||||||||||||||||||||||||||||||||||||||
| 864 | #should be zero | ||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | $d->add($m1->element(1, 1) - $m2->element(1, 1)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 866 | if $_ % 10 == 1; | ||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | $m1 = $smatrix->inverse(); | |||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | $m2 = $smatrix ** -1; | |||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | $m3 = $smatrix->decompose_LR->invert_LR; | |||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | $d->add($m1->element(1, 1), $m2->element(1, 1), $m3->element(1, 1)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 871 | if $_ % 10 == 1; | ||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | sub bench_moose { | ||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_moose: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | my $cnt = 0; | |||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | for (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | my $p = rand(1000); | |||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | my $root = Benchmark::DKbench::MooseTree->new(node => 'root'); | |||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | $root->price($p); | |||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | $root->node; | |||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | $root->cost; | |||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | my $lchild = $root->left; | |||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | $lchild->node('child'); | |||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | $lchild->price($p); | |||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | $lchild->tax; | |||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | my $child = $root->right; | |||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | $child->cost; | |||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | my $grandchild = $child->left; | |||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | $grandchild->node('grandchild'); | |||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | $grandchild->has_parent; | |||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | $grandchild->parent; | |||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | $grandchild->price($p); | |||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | $grandchild->cost; | |||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my $ggchild = $grandchild->right; | |||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | $ggchild->cost; | |||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | $cnt += 5; | |||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | return md5_hex("$cnt objects"); | |||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||
| 906 | sub bench_moose_prv { | ||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_moose_prv: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | my $tdir = catfile($datadir, 't'); | |||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | if ($iter < 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | $tdir = catfile($tdir, 'recipes'); | |||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | $result = `prove -rQ $tdir`; | |||||||||||||||||||||||||||||||||||||||||
| 913 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $result = `prove -rQ $tdir` for (1..$iter); | |||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | ▶ | if ($result =~ /Result: (\w*)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | return $1; | |||||||||||||||||||||||||||||||||||||||||
| 918 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | return '?'; | |||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||
| 923 | sub bench_primes_m { | ||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_primes_m: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | return bench_primes($iter, 7_500_000); | |||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | sub bench_primes { | ||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_primes: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | my $max = shift; | |||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | my @primes; | |||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | @primes = _get_primes($max) for (1..$iter); | |||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | return md5_hex(scalar(@primes)." primes up to $max"); | |||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||
| 936 | sub bench_regex_asc { | ||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_regex_asc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | return bench_regex_subst($iter, ''); | |||||||||||||||||||||||||||||||||||||||||
| 939 | } | ||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||
| 941 | sub bench_regex_utf8 { | ||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_regex_utf8: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | return bench_regex_subst($iter, 'utf8'); | |||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||
| 946 | sub bench_regex_subst { | ||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_regex_subst: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | my $enc = shift; | |||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | my $str = _read_wiki_files($enc); | |||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | my $match = bench_regex($str, $iter); | |||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | my $repl = bench_subst($str, $iter); | |||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | return md5_hex($match, $repl); | |||||||||||||||||||||||||||||||||||||||||
| 953 | } | ||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | sub bench_regex { | ||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | my $str = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_regex: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | my $iter = shift; | |||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | my $count; | |||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | for (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | $count += () = $str =~ /\b[A-Z][a-z]+/g; | |||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | $count += () = $str =~ /([\w\.+-]+)@[\w\.-]+\.([\w\.-]+)/g; | |||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | $count += () = $str =~ m![\w]+://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?!g; | |||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | return "$count Matched"; | |||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||
| 968 | sub bench_subst { | ||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | ▶ | my $str = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_subst: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | my $iter = shift; | |||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | my $count; | |||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | for (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | my $copy = $str; | |||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | ▶ | while (my $s = $copy =~ s#<([^>]+)>([^>]*?)</\1>#$2#g) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | $count += $s; | |||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | $copy = substr($copy, int(rand(100))+1) for 1..10; | |||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | return "$count Replaced"; | |||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||
| 983 | sub bench_textlevenshtein { | ||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_textlevenshtein: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | my $data = _fuzzy_data(); | |||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | my $diff; | |||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | foreach (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | foreach my $sz (qw/10 100 1000 2500/) { | |||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | my $n = scalar @{$data->{$sz}}; | |||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | my $i = int(rand($n)); | |||||||||||||||||||||||||||||||||||||||||
| 992 | $diff = Text::Levenshtein::XS::distance( | ||||||||||||||||||||||||||||||||||||||||||
| 993 | $data->{$sz}->[$i], $data->{$sz}->[$_] | ||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | ) for 0..$n-1; | |||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | ▶ | $d->add($diff || -1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$diff || -1
MC/DC0%0/1
$diff || -1
$diff
Truth table0%0/2
A
A= $diff
| |||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | ▶ | next if $sz > 1000; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 997 | $diff = Text::Levenshtein::Damerau::XS::xs_edistance( | ||||||||||||||||||||||||||||||||||||||||||
| 998 | $data->{$sz}->[$i], $data->{$sz}->[$_] | ||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | ) for 0..$n-1; | |||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | $d->add($diff); | |||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||
| 1006 | sub bench_timepiece { | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | ▶ | my $iter = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bench_timepiece: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | my $t = Time::Piece::localtime(1692119499); | |||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | my $d = Digest->new("MD5"); | |||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | my $day = 3600*24; | |||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | local $ENV{TZ} = 'UTC'; | |||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | for (1..$iter) { | |||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | $t += int(rand(1000)-500)*$day; | |||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | ▶ | $t += 100000*$day if $t->year < 1970; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | my $str = $t->strftime("%w, %d %m %Y %H:%M:%S"); | |||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | eval '$t = Time::Piece->strptime($str, "%w, %d %m %Y %H:%M:%S")'; | |||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | my $jd = $t->julian_day; | |||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | $d->add($str,$jd); | |||||||||||||||||||||||||||||||||||||||||
| 1020 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | return $d->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 1022 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||
| 1024 | sub total_stats { | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | ▶ | my ($opt, $stats) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
total_stats: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | my $benchmarks = benchmark_list(); | |||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | ▶ | my $display = $opt->{time} ? 'times' : 'scores'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | ▶ | my $title = $opt->{time} ? 'Time (sec)' : 'Score'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | print "Aggregates:\n".pad_to("Benchmark",24).pad_to("Avg $title").pad_to("Min $title").pad_to("Max $title"); | |||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | ▶ | print pad_to("Pass %") unless $opt->{time}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | foreach my $bench (sort keys %$benchmarks) { | |||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | ▶ | next unless $stats->{$bench}->{$display}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | my $str = calc_stats($opt, $stats->{$bench}->{$display}); | |||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | print pad_to("$bench:",24).$str; | |||||||||||||||||||||||||||||||||||||||||
| 1036 | print pad_to( | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | sprintf("%d", 100 * ($opt->{iter}-($stats->{$bench}->{fail} || 0)) / $opt->{iter})) | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | ▶ | unless $opt->{time}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$stats->{$bench}{'fail'} || 0
MC/DC0%0/1
$stats->{$bench}{'fail'} || 0
$stats->{$bench}{'fail'}
Truth table0%0/2
A
A= $stats->{$bench}{'fail'}
| |||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | my $str = calc_stats($opt, $stats->{total}->{$display}); | |||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | print pad_to("Overall Avg $title:", 24)."$str\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1043 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||
| 1045 | sub calc_stats { | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | ▶ | my $opt = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calc_stats: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | my $arr = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | my $pad = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | my ($min, $max, $avg) = min_max_avg($arr); | |||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | return $avg, join '', map {pad_to(sprintf($opt->{f}, $_), $pad)} ($avg,$min,$max); | |||||||||||||||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||
| 1053 | sub min_max_avg { | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | 4 | ▶ | my $arr = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
min_max_avg: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1055 | 4 | ▶ | return (0, 0, 0) unless @$arr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1056 | 3 | return min(@$arr), max(@$arr), sum(@$arr)/scalar(@$arr); | |||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | sub avg_stdev { | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | 4 | ▶ | my $arr = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
avg_stdev: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1061 | 4 | ▶ | return (0, 0) unless @$arr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1062 | 3 | my $sum = sum(@$arr); | |||||||||||||||||||||||||||||||||||||||||
| 1063 | 3 | my $avg = $sum/scalar(@$arr); | |||||||||||||||||||||||||||||||||||||||||
| 1064 | 3 | my @sq; | |||||||||||||||||||||||||||||||||||||||||
| 1065 | 3 | push @sq, ($avg - $_)**2 for (@$arr); | |||||||||||||||||||||||||||||||||||||||||
| 1066 | 3 | my $dev = min_max_avg(\@sq); | |||||||||||||||||||||||||||||||||||||||||
| 1067 | 3 | return $avg, sqrt($dev); | |||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | # $single = single tail of dist curve outlier, 1 for over (right), -1 for under (left) | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | sub drop_outliers { | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | 3 | ▶ | my $arr = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
drop_outliers: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1073 | 3 | my $single = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1074 | 3 | my ($avg, $stdev) = avg_stdev($arr); | |||||||||||||||||||||||||||||||||||||||||
| 1075 | 3 | my @newarr; | |||||||||||||||||||||||||||||||||||||||||
| 1076 | 3 | foreach (@$arr) { | |||||||||||||||||||||||||||||||||||||||||
| 1077 | 39 | ▶ | if ($single) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1078 | 26 | ▶ | push @newarr, $_ unless $single*($_ - $avg) > 2*$stdev; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1079 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | 13 | ▶ | push @newarr, $_ unless abs($avg - $_) > 2*$stdev; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | 3 | return @newarr; | |||||||||||||||||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||
| 1086 | sub pad_to { | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | 8 | ▶ | my $str = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pad_to: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1088 | 8 | ▶ | my $len = shift || 20; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 20
MC/DC0%0/1
shift() || 20
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1089 | 8 | return $str." "x($len-length($str)); | |||||||||||||||||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||
| 1092 | sub _read_wiki_files { | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | ▶ | my $enc = shift || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_wiki_files: not called CC=4 SCAR=30.0
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | my $str = ""; | |||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | for (0..2) { | |||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | ▶ | open my $fh, "<:$enc", catfile($datadir,"wiki$_.html") or die $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | $str .= do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1099 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 1100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||
| 1102 | sub _random_str { | ||||||||||||||||||||||||||||||||||||||||||
| 1103 | 3 | ▶ | my $length = shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_random_str: called CC=4 SCAR=13.9
Condition100%2/2
shift() || 1
MC/DC100%1/1
shift() || 1
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1104 | 3 | my $abc = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1105 | 3 | ▶ | my ($base, $rng) = $abc ? (65, 26) : (32, 95); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1106 | 3 | my $str = ""; | |||||||||||||||||||||||||||||||||||||||||
| 1107 | 3 | $str .= chr(int(rand($rng))+$base) for 1..$length; | |||||||||||||||||||||||||||||||||||||||||
| 1108 | 3 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||
| 1111 | sub _random_uchar { | ||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | ▶ | my $chr = int(rand(800))+32; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_random_uchar: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | ▶ | $chr += 128 if $chr > 127; # Skip Latin 1 supplement | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | ▶ | $chr += 288 if $chr > 591; # Skip pre-Greek blocks | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | return chr($chr); | |||||||||||||||||||||||||||||||||||||||||
| 1116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||
| 1118 | sub _fuzzy_data { | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | ▶ | my %data; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fuzzy_data: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | push @{$data{10}}, join('', map {_random_uchar()} 1..(8+int(rand(5)))) | |||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | for 0..99; | |||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | push @{$data{100}}, $data{10}->[$_]x10 for 0..49; | |||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | push @{$data{1000}}, _random_str(50,1)x20 for 0..7; | |||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | push @{$data{2500}}, _random_str(50,1)x50 for 0..3; | |||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | return \%data; | |||||||||||||||||||||||||||||||||||||||||
| 1126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||
| 1128 | sub _rand_where { | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | ▶ | my $p = rand(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rand_where: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | ▶ | if ($p > 0.5) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | return {foo => rand(10)}; | |||||||||||||||||||||||||||||||||||||||||
| 1132 | } elsif ($p > 0.2) { | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | return {bar => {-in => [int($p*10)..int($p*20)]}}; | |||||||||||||||||||||||||||||||||||||||||
| 1134 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | ▶ | my $op = $p > 0.1 ? '-and' : '-or'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | my @cond = map {_rand_where()} 1..int(rand(3)+1); | |||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | return {$op => [@cond]}; | |||||||||||||||||||||||||||||||||||||||||
| 1138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||
| 1141 | sub _db_data { | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | ▶ | my (@data, @cols); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_db_data: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | foreach (1..20) { | |||||||||||||||||||||||||||||||||||||||||
| 1144 | my $d = { | ||||||||||||||||||||||||||||||||||||||||||
| 1145 | id => int(rand(10000000)), | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | date => \"NOW()", | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | map {"data".$_ => "foo bar" x int(rand(5)+1)} 1..int(rand(20)+1) | |||||||||||||||||||||||||||||||||||||||||
| 1148 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | push @data, $d; | |||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | push @cols, [sort keys %$d]; | |||||||||||||||||||||||||||||||||||||||||
| 1151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | return \@data, \@cols; | |||||||||||||||||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||
| 1155 | sub compare_obj { | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | 4 | ▶ | my ($obj1, $obj2) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_obj: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1157 | 4 | my $t1 = ref($obj1); | |||||||||||||||||||||||||||||||||||||||||
| 1158 | 4 | my $t2 = ref($obj2); | |||||||||||||||||||||||||||||||||||||||||
| 1159 | 4 | ▶ | return 0 if $t1 ne $t2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1160 | 3 | ▶ | return $obj1 eq $obj2 unless $t1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | return $t1 eq 'ARRAY' ? compare_arr($obj1, $obj2) : compare_hash($obj1, $obj2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||
| 1164 | sub compare_arr { | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | 2 | ▶ | my ($arr1, $arr2) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_arr: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1166 | 2 | my $sz = scalar @$arr1; | |||||||||||||||||||||||||||||||||||||||||
| 1167 | 2 | ▶ | return 0 if $sz != scalar @$arr2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1168 | 1 | for (0..$sz-1) { | |||||||||||||||||||||||||||||||||||||||||
| 1169 | 2 | ▶ | return 0 unless compare_obj($arr1->[$_], $arr2->[$_]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||
| 1174 | sub compare_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 1175 | 2 | ▶ | my ($h1, $h2) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_hash: called CC=4 SCAR=14.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1176 | 2 | ▶ | return 0 if scalar keys %$h1 != scalar keys %$h2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1177 | 1 | for (keys %$h1) { | |||||||||||||||||||||||||||||||||||||||||
| 1178 | 1 | ▶ | return 0 unless compare_obj($h1->{$_}, $h2->{$_}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||
| 1183 | sub rand_arr { | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | ▶ | my $sz = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rand_arr: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | my @arr; | |||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | for (1..$sz) { | |||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | my $len = int(rand(10)) + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | ▶ | my $item = rand(1) < 0.9 ? _random_uchar()x($len*5) : rand(1) < 0.5 ? rand_arr($len) : rand_hash($len); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | push @arr, $item; | |||||||||||||||||||||||||||||||||||||||||
| 1190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | return \@arr; | |||||||||||||||||||||||||||||||||||||||||
| 1192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||
| 1194 | sub rand_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | ▶ | my $sz = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rand_hash: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | my %hash; | |||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | for (1..$sz) { | |||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | my $len = int(rand(10)) + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | ▶ | my $item = rand(1) < 0.9 ? _random_uchar()x($len*5) : rand(1) < 0.5 ? rand_arr($len) : rand_hash($len); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | $hash{_random_uchar()x($len*4)} = $item; | |||||||||||||||||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1202 | 0 | return \%hash; | |||||||||||||||||||||||||||||||||||||||||
| 1203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||
| 1205 | # modified from https://github.com/famzah/langs-performance/blob/master/primes.pl | ||||||||||||||||||||||||||||||||||||||||||
| 1206 | sub _get_primes { | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | ▶ | my $n = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_primes: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | my @s = (); | |||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | ▶ | for (my $i = 3; $i < $n + 1; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | push(@s, $i); | |||||||||||||||||||||||||||||||||||||||||
| 1211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | my $mroot = $n**0.5; | |||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | my $half = scalar @s; | |||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | my $m = 3; | |||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | ▶ | while ($m <= $mroot) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | ▶ | if ($s[$i]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | ▶ | for (my $j = int(($m * $m - 3) / 2); $j < $half; $j += $m) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | $s[$j] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | $m = 2 * $i + 3; | |||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||
| 1226 | 0 | return 2, grep($_, @s); | |||||||||||||||||||||||||||||||||||||||||
| 1227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||
| 1229 | # Fix for Crypt::JWT that was submitted as a patch. Will remove if it is merged. | ||||||||||||||||||||||||||||||||||||||||||
| 1230 | sub _decode_jwt2 { | ||||||||||||||||||||||||||||||||||||||||||
| 1231 | 1 | ▶ | my %args = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_jwt2: called CC=4 SCAR=19.4
| |||||||||||||||||||||||||||||||||||||||||||
| 1232 | 1 | my ($header, $payload); | |||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||
| 1234 | 1 | ▶ | if ($args{token} =~ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1235 | /^([a-zA-Z0-9_-]+)=*\.([a-zA-Z0-9_-]*)=*\.([a-zA-Z0-9_-]*)=*(?:\.([a-zA-Z0-9_-]+)=*\.([a-zA-Z0-9_-]+)=*)?$/ | ||||||||||||||||||||||||||||||||||||||||||
| 1236 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | ▶ | if (length($5)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1238 | # JWE token (5 segments) | ||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | ($header, $payload) = | |||||||||||||||||||||||||||||||||||||||||
| 1240 | Crypt::JWT::_decode_jwe($1, $2, $3, $4, $5, undef, {}, {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1241 | %args); | ||||||||||||||||||||||||||||||||||||||||||
| 1242 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1243 | # JWS token (3 segments) | ||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | ($header, $payload) = | |||||||||||||||||||||||||||||||||||||||||
| 1245 | Crypt::JWT::_decode_jws($1, $2, $3, {}, %args); | ||||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1248 | 1 | ▶ | return ($header, $payload) if $args{decode_header}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | return $payload; | |||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||
| 1252 | # Helper package for Moose benchmark | ||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||
| 1254 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | package Benchmark::DKbench::MooseTree; | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||
| 1257 | 3 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||
| 1259 | 3 | has 'price' => (is => 'rw', default => 10); | |||||||||||||||||||||||||||||||||||||||||
| 1260 | 3 | has 'tax' => (is => 'rw', lazy_build => 1); | |||||||||||||||||||||||||||||||||||||||||
| 1261 | 3 | has 'node' => (is => 'rw', isa => 'Any'); | |||||||||||||||||||||||||||||||||||||||||
| 1262 | 3 | has 'parent' => ( | |||||||||||||||||||||||||||||||||||||||||
| 1263 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 1264 | isa => 'Benchmark::DKbench::MooseTree', | ||||||||||||||||||||||||||||||||||||||||||
| 1265 | predicate => 'has_parent', | ||||||||||||||||||||||||||||||||||||||||||
| 1266 | weak_ref => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | 3 | has 'left' => ( | |||||||||||||||||||||||||||||||||||||||||
| 1269 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 1270 | isa => 'Benchmark::DKbench::MooseTree', | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | predicate => 'has_left', | ||||||||||||||||||||||||||||||||||||||||||
| 1272 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1273 | builder => '_build_child_tree', | ||||||||||||||||||||||||||||||||||||||||||
| 1274 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | 3 | has 'right' => ( | |||||||||||||||||||||||||||||||||||||||||
| 1276 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 1277 | isa => 'Benchmark::DKbench::MooseTree', | ||||||||||||||||||||||||||||||||||||||||||
| 1278 | predicate => 'has_right', | ||||||||||||||||||||||||||||||||||||||||||
| 1279 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1280 | builder => '_build_child_tree', | ||||||||||||||||||||||||||||||||||||||||||
| 1281 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1282 | before 'right', 'left' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | ▶ | my ($self, $tree) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | ▶ | $tree->parent($self) if defined $tree; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1285 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||
| 1287 | sub _build_tax { | ||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_tax: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | $self->price * 0.2; | |||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||
| 1292 | sub _build_child_tree { | ||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_child_tree: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | return Benchmark::DKbench::MooseTree->new( parent => $self ); | |||||||||||||||||||||||||||||||||||||||||
| 1295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||
| 1297 | sub cost { | ||||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cost: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | $self->price + $self->tax; | |||||||||||||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||
| 1303 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||