UNPKG

sku-pg

Version:

Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser!

58 lines (52 loc) 1.59 kB
<!DOCTYPE html> <html> <!-- Copyright 2006 The Closure Library Authors. All Rights Reserved. Use of this source code is governed by the Apache License, Version 2.0. See the COPYING file for details. --> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Closure Unit Tests - goog.util.Tracer</title> <script src="../base.js"></script> <script> goog.require('goog.debug.Trace'); goog.require('goog.testing.jsunit'); </script> </head> <body> <script> function testTracer() { goog.debug.Trace.initCurrentTrace(); var t = goog.debug.Trace.startTracer('foo'); var sum = 0; for (var i = 0; i < 100000; i++) { sum += i; } goog.debug.Trace.stopTracer(t); var trace = goog.debug.Trace.getFormattedTrace(); var lines = trace.split('\n'); assertEquals(8, lines.length); assertNotNull(lines[0].match(/^\s*\d+\.\d+\s+Start\s+foo$/)); assertNotNull(lines[1].match(/^\s*\d+\s+\d+\.\d+\s+Done\s+\d+ ms\s+foo$/)); } function testPerf() { goog.debug.Trace.initCurrentTrace(); var count = 1000; var start = goog.now(); for (var i = 0; i < count; i++) { var t = goog.debug.Trace.startTracer('foo'); var t2 = goog.debug.Trace.startTracer('foo.bar'); var t3 = goog.debug.Trace.startTracer('foo.bar.baz'); goog.debug.Trace.stopTracer(t3); var t4 = goog.debug.Trace.startTracer('foo.bar.bim'); goog.debug.Trace.stopTracer(t4); goog.debug.Trace.stopTracer(t2); goog.debug.Trace.stopTracer(t); } count *= 4; var end = goog.now(); } </script> </body> </html>