# How to access timings of each individual test in a TestReport?

I want to know how long each VerificationTest took to complete in the test report, so see which one was the longest and do some statistics on them:

TestReport[
Table[VerificationTest[
FullSimplify[2 Sin[12 x + 15 y] Cos[14 x + 21 y]],
Simplify[2 Sin[12 x + 15 y] Cos[14 x + 21 y]]], {10}]]


The most straightforward method seems to be to map the test property you are looking for over the TestReportObject, as follows:

report = TestReport[{VerificationTest[Limit[Exp[t], t -> 0], 2],
VerificationTest[PrimeQ[7]],
VerificationTest[Factor[1 - 2 x + x^2], (x + 1)^2],
VerificationTest[Infinity - Infinity, Indeterminate]}];

Map[#["AbsoluteTimeUsed"] &]@report["TestResults"]
(*
<|1 -> Quantity[0.029815, "Seconds"],
2 -> Quantity[0.000135, "Seconds"],
3 -> Quantity[0.000217, "Seconds"],
4 -> Quantity[0.001597, "Seconds"]|>
*)


An alternative, is to use Query:

Query[All, (#["AbsoluteTimeUsed"] &)]@report["TestResults"]


which produces identical results. It is more verbose than Map, but it is potentially cleaner.

The cleanest method, as pointed out by Ilian, is to use Through, e.g.

Through[Values[report["TestResults"]]["AbsoluteTimeUsed"]]


even though it is not the shortest character wise.

• I concur that this is the best way to do this. – Stefan R Jul 7 '15 at 20:08
• The #[]&/@ syntax isn't the prettiest. – M.R. Jul 7 '15 at 23:23
• It's not, but I found one with Query. Will add it. – rcollyer Jul 8 '15 at 1:07
• For just the timings (and prettier syntax), maybe Through[Values[report["TestResults"]]["AbsoluteTimeUsed"]]. – ilian Jul 8 '15 at 2:01