MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / TestResult

Class TestResult

examples/performance/__init__.py:408–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406
407
408class TestResult:
409 def __init__(
410 self, profile, test, stats=None, total_time=None, sort="cumulative"
411 ):
412 self.profile = profile
413 self.test = test
414 self.stats = stats
415 self.total_time = total_time
416 self.sort = sort
417
418 def report(self):
419 print(self._summary())
420 if self.profile.profile:
421 self.report_stats()
422
423 def _summary(self):
424 summary = "%s : %s (%d iterations)" % (
425 self.test.__name__,
426 self.test.__doc__,
427 self.profile.num,
428 )
429 if self.total_time:
430 summary += "; total time %f sec" % self.total_time
431 if self.stats:
432 summary += "; total fn calls %d" % self.stats.total_calls
433 return summary
434
435 def report_stats(self):
436 if self.profile.dump:
437 self._dump(self.sort)
438 elif self.profile.raw:
439 self._dump_raw()
440
441 def _dump(self, sort):
442 self.stats.sort_stats(*re.split(r"[ ,]", self.sort))
443 self.stats.print_stats()
444 if self.profile.callers:
445 self.stats.print_callers()
446
447 def _dump_raw(self):
448 self.stats.dump_stats(self.profile.raw)

Callers 2

_run_with_profileMethod · 0.85
_run_with_timeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected