Parameterized unit testing and benchmarking of phobos

Robert burner Schadek via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 8 14:37:54 PDT 2014


Lately, I find myself wondering, if I should add parameterized 
unit tests to std.string, because the last few bugs I fixed where 
not caught by tests, as the test-data was not good enough. I know 
random data is not perfect either, but it would be good addition 
IMO.

Additionally, I thought these unit tests could be used to 
benchmark the performance of the functions and the compilers. 
Thus allowing continues monitoring of performance changes.

I'm thinking of something like:

version(unittest_benchmark) {
unittest {
     auto ben = Benchmark("bench_result_file", numberOfRuns);
     auto values = ValueGen!(StringGen(0, 12), IntGen(2, 24))(ben);

     foreach(string rStr, int rInt; values) {
         auto rslt = functionToTest(rStr, rInt);
         // some asserts
     }
}
}

The bench_result_file would be a csv with e.g. date,runtime,...

ideas, suggestions?


More information about the Digitalmars-d mailing list