<s> import sys <EOL> import pstats <EOL> import cProfile <EOL> import unittest <EOL> from django . test . simple import DjangoTestSuiteRunner <EOL> class ProfilingTestRunner ( DjangoTestSuiteRunner ) : <EOL> def run_suite ( self , suite , ** kwargs ) : <EOL> stream = open ( '<STR_LIT>' , '<STR_LIT:w>' ) <EOL> if sys . version_info >= ( <NUM_LIT:2> , <NUM_LIT:7> ) : <EOL> runner = unittest . TextTestRunner ( <EOL> verbosity = self . verbosity , failfast = self . failfast ) . run <EOL> else : <EOL> runner = unittest . TextTestRunner ( verbosity = self . verbosity ) . run <EOL> profile = cProfile . Profile ( ) <EOL> profile . runctx ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : runner , <EOL> '<STR_LIT>' : suite , <EOL> } , locals ( ) ) <EOL> profile . create_stats ( ) <EOL> stats = pstats . Stats ( profile , stream = stream ) <EOL> stats . sort_stats ( '<STR_LIT:time>' ) <EOL> stats . print_stats ( ) <EOL> return locals ( ) [ '<STR_LIT:result>' ] </s>
