From 15b92851ed575f4c2090814962cbd50404656109 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 27 Apr 2011 04:58:15 +0300 Subject: [PATCH] Add a profiling harness --- pokedex/tests/test_movesets.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pokedex/tests/test_movesets.py b/pokedex/tests/test_movesets.py index 11a7283..31b6139 100644 --- a/pokedex/tests/test_movesets.py +++ b/pokedex/tests/test_movesets.py @@ -45,4 +45,16 @@ def test_cases(): args = argstring.split() assert main(args[1:]) == result_map[args[0]] run_test.description = 'Moveset checker test: ' + argstring.strip() - yield run_test, argstring + yield run_test, argstring.strip() + + +if __name__ == '__main__': + filename = 'movesets.profile' + print 'Profiling the moveset checker' + import cProfile + def header(str): + print + print str + cProfile.runctx("[(header(arg), f(arg)) for f, arg in test_cases()]", + globals(), locals(), filename=filename) + print 'Profile stats saved to', filename