Пример #1
0
 def test_merge(self):
     c1 = metrics.StopWatch("foo")
     c2 = metrics.StopWatch("bar")
     with c1:
         pass
     with c2:
         pass
     t1 = c1._total
     t2 = c2._total
     c1._merge(c2)
     t3 = c1._total
     self.assertGreaterEqual(t3, t1)
     self.assertGreaterEqual(t3, t2)
Пример #2
0
def main():
    try:
        options = config.Options(sys.argv[1:], command_line=True)
    except utils.UsageError as e:
        print(str(e), file=sys.stderr)
        sys.exit(1)

    if options.show_config:
        print(options)
        sys.exit(0)

    if options.version:
        print(io.get_pytype_version())
        sys.exit(0)

    node.SetCheckPreconditions(options.check_preconditions)

    if options.timeout is not None:
        signal.alarm(options.timeout)

    with _ProfileContext(options.profile):
        with metrics.MetricsContext(options.metrics, options.open_function):
            with metrics.StopWatch("total_time"):
                with metrics.Snapshot("memory",
                                      enabled=options.memory_snapshots):
                    return _run_pytype(options)
Пример #3
0
 def test_summary(self):
     c1 = metrics.StopWatch("foo")
     with c1:
         pass
     self.assertIsInstance(c1._summary(), str)
     self.assertIsInstance(str(c1), str)
Пример #4
0
 def test_stopwatch(self):
     c = metrics.StopWatch("foo")
     with c:
         pass
     self.assertGreaterEqual(c._total, 0)