1
0

perfplugin.py 884 B

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