1
1
# NAME
2
2
3
- Benchmark::DKbench - Perl CPU Benchmark
3
+ Benchmark::DKbench - Perl CPU Benchmark Suite
4
4
5
5
# SYNOPSIS
6
6
@@ -237,21 +237,31 @@ exported functions that the `dkbench` script uses for reference:
237
237
238
238
## ` system_identity `
239
239
240
- my $cores = system_identity();
240
+ my $cores = system_identity($quiet? );
241
241
242
- Prints out software/hardware configuration and returns the number of cores detected.
242
+ Prints out software/hardware configuration and returns the number of logical cores
243
+ detected using [ System::CPU] ( https://metacpan.org/pod/System%3A%3ACPU ) .
244
+
245
+ Any argument will suppress printout and will only return the number of cores.
243
246
244
247
## ` suite_run `
245
248
246
249
my %stats = suite_run(\%options);
247
250
248
251
Runs the benchmark suite given the ` %options ` and prints results. Returns a hash
249
- with run stats.
252
+ with run stats that looks like this:
253
+
254
+ %stats = (
255
+ bench_name => {times => [ ... ], scores => [ ... ]},
256
+ ...
257
+ _total => {times => [ ... ], scores => [ ... ]},
258
+ _opt => {iter => $iterations, threads => $no_threads, ...}
259
+ );
250
260
251
261
The options of the ` dkbench ` script (in their long form) are accepted, except
252
262
` help ` , ` setup ` and ` max_threads ` which are exclusive to the command-line script.
253
263
254
- In addition, ` %options ` may contain the key ` % extra_bench` , with a hashref value
264
+ In addition, ` %options ` may contain the key ` extra_bench ` , with a hashref value
255
265
containing custom benchmarks in the following format:
256
266
257
267
extra_bench => { bench_name => [$coderef, $exp_output, $ref_time, $quick_arg, $normal_arg], ... }
@@ -268,10 +278,19 @@ For more info with an example see the ["CUSTOM BENCHMARKS"](#custom-benchmarks)
268
278
269
279
## ` calc_scalability `
270
280
271
- calc_scalability(\%options, \%stat_single, \%stat_multi);
281
+ my %scal = calc_scalability( \%stat_single, \%stat_multi);
272
282
273
283
Given the ` %stat_single ` results of a single-threaded ` suite_run ` and ` %stat_multi `
274
- results of a multi-threaded run, will calculate and print the multi-thread scalability.
284
+ results of a multi-threaded run, will calculate, print and return the multi-thread
285
+ scalability (including averages, ranges etc for multiple iterations.
286
+
287
+ The result hash return looks like this:
288
+
289
+ %scal = (
290
+ bench_name => $bench_avg_scalability,
291
+ ...
292
+ _total => $total_avg_scalability
293
+ );
275
294
276
295
# CUSTOM BENCHMARKS
277
296
@@ -290,10 +309,8 @@ with the default benchmarks:
290
309
my $iter = shift || 1; # Optionally have an argument that scales the workload
291
310
my $dist = 0;
292
311
$dist +=
293
- great_circle_distance(rand(pi), rand(2 * pi), rand(pi), rand(2 * pi)) -
294
- great_circle_bearing(rand(pi), rand(2 * pi), rand(pi), rand(2 * pi)) +
295
- great_circle_direction(rand(pi), rand(2 * pi), rand(pi), rand(2 * pi))
296
- for 1 .. $iter;
312
+ great_circle_distance(rand(pi), rand(2 * pi), rand(pi), rand(2 * pi))
313
+ for 1 .. $iter;
297
314
return $dist; # Returning something is optional, but is used to Fail bench on no match
298
315
}
299
316
@@ -303,8 +320,8 @@ with the default benchmarks:
303
320
\&great_circle, # Reference to bench function
304
321
'3144042.81433949', # Output for your reference Perl - determines Pass/Fail (optional)
305
322
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)
323
+ 1000000, # Argument to pass for --quick mode (optional)
324
+ 5000000 # Argument to pass for normal mode (optional)
308
325
]},
309
326
}
310
327
);
@@ -316,10 +333,21 @@ to run by itself:
316
333
317
334
my %stats = suite_run({
318
335
include => 'custom',
319
- extra_bench => { custom1 => [sub {split //, 'x'x$_ for 1..10000}] }
336
+ extra_bench => { custom1 => [sub {my @a=split( //, 'x'x$_) for 1..10000}] }
320
337
}
321
338
);
322
339
340
+ If you want to do a multi-threaded run as well and then calculate scalability:
341
+
342
+ my %stats_multi = suite_run({
343
+ threads => system_identity(1);
344
+ include => 'custom',
345
+ extra_bench => { custom1 => [sub {my @a=split(//, 'x'x$_) for 1..10000}] }
346
+ }
347
+ );
348
+
349
+ my %scal = calc_scalability(\%stats, \%stats_multi);
350
+
323
351
# NOTES
324
352
325
353
The benchmark suite was created to compare the performance of various cloud offerings.
0 commit comments