perfplugin.py 925 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. """
  3. (c) 2017 - Copyright Red Hat Inc
  4. Authors:
  5. Patrick Uiterwijk <puiterwijk@redhat.com>
  6. """
  7. from __future__ import unicode_literals
  8. import logging
  9. import os
  10. from nose.plugins import Plugin
  11. import perfrepo
  12. log = logging.getLogger('nose.plugins.perfplugin')
  13. class PerfPlugin(Plugin):
  14. """A plugin for Nose that reports back on the test performance."""
  15. name = 'pagureperf'
  16. def options(self, parser, env=None):
  17. if env is None:
  18. env = os.environ
  19. super(PerfPlugin, self).options(parser, env=env)
  20. def configure(self, options, conf):
  21. super(PerfPlugin, self).configure(options, conf)
  22. if not self.enabled:
  23. return
  24. def report(self, stream):
  25. stream.write('GIT PERFORMANCE TOTALS:\n')
  26. stream.write('\tWalks: %d\n' % perfrepo.TOTALS['walks'])
  27. stream.write('\tSteps: %d\n' % perfrepo.TOTALS['steps'])