3

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}]]
rcollyer
  • 33,976
  • 7
  • 92
  • 191
M.R.
  • 31,425
  • 8
  • 90
  • 281

1 Answers1

6

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.

rcollyer
  • 33,976
  • 7
  • 92
  • 191