Skip to content

Commit ba2e6ac

Browse files
committed
v2.6 - Improve custom benchmarks
1 parent bd43676 commit ba2e6ac

File tree

6 files changed

+175
-106
lines changed

6 files changed

+175
-106
lines changed

Changes

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Revision history for Benchmark-DKbench
22

3-
2.4 2024-04-24
3+
2.6 2024-04-25
4+
- Custom benchmark improvements.
5+
- Fix BSD tar xattr.
6+
7+
2.5 2024-04-24
48
- Added support for custom benchmarks.
59
- Corrected BioPerl Codons bench.
610
- Updated some reference modules.

README.md

+30-18
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ scenario - even allowing you to add your own custom benchmarks.
3030

3131
See the ["setup\_dkbench"](#setup_dkbench) script below for more on the installation of a couple
3232
of optional benchmarks and standardizing your benchmarking environment, otherwise
33-
here are some general guidelines for verious systems.
33+
here are some general guidelines for various systems.
3434

3535
## Linux / WSL etc
3636

@@ -60,7 +60,7 @@ the benchmark suite.
6060
## Strawberry Perl
6161

6262
If you are on Windows, you should be using the Windows Subsystem for Linux (WSL)
63-
for running Perl or, if you can't (e.g. old Windows verions), cygwin instead.
63+
for running Perl or, if you can't (e.g. old Windows versions), cygwin instead.
6464
The suite should still work on Strawberry Perl, as long as you don't try to run
6565
tests when installing (some dependencies will not pass them). The simplest way is
6666
with [App::cpanminus](https://metacpan.org/pod/App%3A%3Acpanminus) (most Strawberry Perl verions have it installed):
@@ -239,7 +239,7 @@ exported functions that the `dkbench` script uses for reference:
239239

240240
my $cores = system_identity();
241241

242-
Prints out software/hardware configuration and returns then number of cores detected.
242+
Prints out software/hardware configuration and returns the number of cores detected.
243243

244244
## `suite_run`
245245

@@ -254,14 +254,17 @@ The options of the `dkbench` script (in their long form) are accepted, except
254254
In addition, `%options` may contain the key `%extra_bench`, with a hashref value
255255
containing custom benchmarks in the following format:
256256

257-
extra_bench => { bench_name => [$exp_output, $ref_time, $coderef, $quick_arg, $normal_arg] ... }
257+
extra_bench => { bench_name => [$coderef, $exp_output, $ref_time, $quick_arg, $normal_arg], ... }
258258

259259
Where `bench_name` is a unique name for each benchmark and the arrayref assigned
260-
to it contains: The expected output (string) for the test to be considered a pass,
261-
the reference time in seconds for a score of 1000, a reference to the actual bench
262-
function, an argument (workload scaling) to pass to the function for the `quick`
263-
bench run and an argument to pass for the normal run. For more info with an example
264-
see the ["CUSTOM BENCHMARKS"](#custom-benchmarks) section.
260+
to it contains: A reference to the benchmarking code, the expected output (string)
261+
for the test to be considered a pass, the reference time in seconds for a score of
262+
1000, an argument (workload scaling) to pass to the function for the `quick` bench
263+
run and an argument to pass for the normal run. If the second argument is undef,
264+
a "Pass" is always recorded, if the third argument is not defined and non-zero,
265+
`time` will be implied.
266+
267+
For more info with an example see the ["CUSTOM BENCHMARKS"](#custom-benchmarks) section.
265268

266269
## `calc_scalability`
267270

@@ -275,7 +278,7 @@ results of a multi-threaded run, will calculate and print the multi-thread scala
275278
Version 2.5 introduced the ability to add custom benchmarks to be run along any
276279
of the included ones of the suite. This allows you to create a suite that is more
277280
relevant to you, by including the actual code you will be running on the systems
278-
you are benchmarking. Remember, the best benchmark is your own code.
281+
you are benchmarking.
279282

280283
Here is an example of adding a benchmark to the test suite and running it together
281284
with the default benchmarks:
@@ -291,22 +294,31 @@ with the default benchmarks:
291294
great_circle_bearing(rand(pi), rand(2 * pi), rand(pi), rand(2 * pi)) +
292295
great_circle_direction(rand(pi), rand(2 * pi), rand(pi), rand(2 * pi))
293296
for 1 .. $iter;
294-
return $dist;
297+
return $dist; # Returning something is optional, but is used to Fail bench on no match
295298
}
296299

297300
my %stats = suite_run({
298301
extra_bench => { 'Math::Trig' => # A unique name for the benchmark
299302
[
300-
'3144042.81433949', # The output for your reference Perl - determines Pass/Fail
301-
5.5, # Seconds to complete in normal mode for score = 1000
302303
\&great_circle, # Reference to bench function
303-
400000, # Argument to pass for --quick mode (if needed)
304-
2000000 # Argument to pass for normal mode (if needed)
304+
'3144042.81433949', # Output for your reference Perl - determines Pass/Fail (optional)
305+
5.5, # Seconds to complete in normal mode for score = 1000 (optional)
306+
400000, # Argument to pass for --quick mode (optional)
307+
2000000 # Argument to pass for normal mode (optional)
305308
]},
306309
}
307310
);
308311

309-
You can pass the `include` option to run only the custom benchmark(s).
312+
You can use a prefix for the naming of your custom benchmarks and make use of the
313+
`include` argument to run only the custom benchmarks. Here is an example, where
314+
a custom test is defined inline, without any of the optional arguments and specified
315+
to run by itself:
316+
317+
my %stats = suite_run({
318+
include => 'custom',
319+
extra_bench => { custom1 => [sub {split //, 'x'x$_ for 1..10000}] }
320+
}
321+
);
310322

311323
# NOTES
312324

@@ -319,9 +331,9 @@ on the servers I was testing, in order to choose the optimal types for the compa
319331
I was working for. The second version has expanded a bit over that, and is friendlier
320332
to use.
321333

322-
Althought this benchmark is in general a good indicator of general CPU performance
334+
Although this benchmark is in general a good indicator of general CPU performance
323335
and can be customized to your needs, no benchmark is as good as running your own
324-
actual workload.
336+
actual workload (which can be done via the ["CUSTOM BENCHMARKS"](#custom-benchmarks) functionality).
325337

326338
## SCORES
327339

0 commit comments

Comments
 (0)