Bug 15559 – std.datetime.benchmark should offer a tear down option

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-01-12T19:55:57Z
Last change time
2024-12-01T16:25:48Z
Assigned to
No Owner
Creator
Jack Stouffer
Moved to GitHub: phobos#9672 →

Comments

Comment #0 by jack — 2016-01-12T19:55:57Z
Consider, ------------- import std.stdio; import std.datetime; import std.conv : to; import std.algorithm; import std.range : iota; import std.array : array; import std.random; enum array_size = 6_000_000; double[] some_array; auto sortTest() { some_sort(some_array); } void main() { // data construction foreach (i; 0 .. array_size) some_array ~= uniform(0.0, 10000.0); // benchmark auto r = benchmark!(sortTest)(1); auto random_result = to!Duration(r[0]); } ------------- This benchmark cannot be run more than once because some_sort has side effects. This loses the averaging that you can get to get rid of outliers by running benchmarks several thousand times. If benchmark had some option to pass a teardown function that would be called at the end of every test, then this could be run many times.
Comment #1 by robert.schadek — 2024-12-01T16:25:48Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9672 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB