#!/usr/bin/env python
#
# Performance profile test code.
#
import sys
from optparse import OptionParser
import dm.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 = "dm.testrunner.run()"
    elif len(args) == 1:
        code = "dm.testrunner.run('%s')" % args[0]
    else:
        print 'ERROR: you have supplied too many arguments\n'
        parser.print_help()
        sys.exit(0)
    profile.run(code)

