Exemplo n.º 1
0
Arquivo: tests.py Projeto: amjith/peek
def collect():
    collector = Collector()
    collector.start()

    function_one(' world')

    collector.stop()

    return collector
Exemplo n.º 2
0
def main(argv=None):
    if argv is None:
        argv = sys.argv[1:]

    from peek.collector import Collector
    from peek.reporter import HTMLReporter

    collector = Collector()
    collector.start()

    try:
        run_python_file(argv[0], argv)
    finally:
        collector.stop()

        reporter = HTMLReporter(argv[0], collector)
        reporter.report()
Exemplo n.º 3
0
def main(argv=None):
    from optparse import OptionParser

    if argv is None:
        argv = sys.argv[1:]

    usage = "python -m peek [-o output_file_path] scriptfile [arg] ..."
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option('-o', '--output', dest="output",
        help="Save stats to <outfile> directory", default=None)

    if not argv:
        parser.print_usage()
        sys.exit(2)

    (options, args) = parser.parse_args()
    sys.argv[:] = args

    if len(args) > 0:
        progname = args[0]
        sys.path.insert(0, os.path.dirname(progname))

        from peek.collector import Collector
        from peek.reporter import HTMLReporter

        collector = Collector(log=(not options.output))
        collector.start()

        try:
            run_python_file(progname, args)
        finally:
            collector.stop()

            reporter = HTMLReporter(progname, collector, output=options.output)
            reporter.report()

    else:
        parser.print_usage()