cbeust/testng — pull request #231 by fpavageau (2012-06-11 09:19:34+00:00)
Title: (Final) performance improvements for FailedReporter

With a fresh eye on a monday morning, I found the real performance problem: for each failed test method, FailedReporter calls MethodHelper.getMethodsDependedUpon() with the same array (all the test methods), which creates a new Graph solely based on the array. Since the graph is not modified by the findPredecessors() call, it can be reused.

Adding a cache to keep this detail internal, I get the wanted improvement:
- before:
Tests run: 7900, Failures: 415, Errors: 0, Skipped: 7271, Time elapsed: 232.967 sec <<< FAILURE!
- after:
Tests run: 7900, Failures: 415, Errors: 0, Skipped: 7271, Time elapsed: 20.884 sec <<< FAILURE!

However, maybe you want to expose the topologicalSort() method instead, so it can be called by FailedReporter once. And of course, the cache only works because the array of methods is never copied.