#!/usr/bin/env python
#
# Profile Kforge code performance.
#
import sys
from optparse import OptionParser
import kforge.testrunner
import profile

if __name__ == "__main__":
    
    usage  = 'usage: %prog [options] [test_module]'
    usage += '\n\tmodule_name specifies the module to test. '
    usage += 'If none supplied then run all tests.'
    parser = OptionParser(usage)
    
    (options, args) = parser.parse_args()
    if len(args) == 0:
        code = "kforge.testrunner.run()"
    elif len(args) == 1:
        code = "kforge.testrunner.run('%s')" % args[0]
    else:
        print 'ERROR: you have supplied too many arguments\n'
        parser.print_help()
        sys.exit(0)
    profile.run(code)
