本文整理汇总了Java中com.google.javascript.jscomp.PerformanceTracker.Stats类的典型用法代码示例。如果您正苦于以下问题:Java Stats类的具体用法?Java Stats怎么用?Java Stats使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Stats类属于com.google.javascript.jscomp.PerformanceTracker包,在下文中一共展示了Stats类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testStatsCalculation
import com.google.javascript.jscomp.PerformanceTracker.Stats; //导入依赖的package包/类
public void testStatsCalculation() {
PerformanceTracker tracker =
new PerformanceTracker(emptyExternRoot, emptyJsRoot, TracerMode.ALL, null);
CodeChangeHandler handler = tracker.getCodeChangeHandler();
// It's sufficient for this test to assume that a single run of any pass
// takes some fixed amount of time, say 5ms.
int passRuntime = 5;
tracker.recordPassStart("noloopA", true);
handler.reportChange();
tracker.recordPassStop("noloopA", passRuntime);
tracker.recordPassStart("noloopB", true);
handler.reportChange();
tracker.recordPassStop("noloopB", passRuntime);
tracker.recordPassStart("loopA", false);
handler.reportChange();
tracker.recordPassStop("loopA", passRuntime);
tracker.recordPassStart("loopA", false);
tracker.recordPassStop("loopA", passRuntime);
tracker.recordPassStart("noloopB", true);
handler.reportChange();
tracker.recordPassStop("noloopB", passRuntime);
tracker.recordPassStart("loopB", false);
tracker.recordPassStop("loopB", passRuntime);
tracker.recordPassStart("noloopB", true);
tracker.recordPassStop("noloopB", passRuntime);
int numRuns = tracker.getRuns();
assertEquals(7, numRuns);
assertEquals(tracker.getRuntime(), numRuns * passRuntime);
assertEquals(3, tracker.getLoopRuns());
assertEquals(4, tracker.getChanges()); /* reportChange was called 4 times */
assertEquals(1, tracker.getLoopChanges());
ImmutableMap<String, Stats> stats = tracker.getStats();
Stats st = stats.get("noloopA");
assertEquals(1, st.runs);
assertEquals(st.runtime, passRuntime);
assertEquals(1, st.changes);
st = stats.get("noloopB");
assertEquals(3, st.runs);
assertEquals(st.runtime, 3 * passRuntime);
assertEquals(2, st.changes);
st = stats.get("loopA");
assertEquals(2, st.runs);
assertEquals(st.runtime, 2 * passRuntime);
assertEquals(1, st.changes);
st = stats.get("loopB");
assertEquals(1, st.runs);
assertEquals(st.runtime, passRuntime);
assertEquals(0, st.changes);
}
示例2: testStatsCalculation
import com.google.javascript.jscomp.PerformanceTracker.Stats; //导入依赖的package包/类
public void testStatsCalculation() {
PerformanceTracker tracker =
new PerformanceTracker(emptyScript, TracerMode.ALL);
CodeChangeHandler handler = tracker.getCodeChangeHandler();
// It's sufficient for this test to assume that a single run of any pass
// takes some fixed amount of time, say 5ms.
int passRuntime = 5;
tracker.recordPassStart("noloopA", true);
handler.reportChange();
tracker.recordPassStop("noloopA", passRuntime);
tracker.recordPassStart("noloopB", true);
handler.reportChange();
tracker.recordPassStop("noloopB", passRuntime);
tracker.recordPassStart("loopA", false);
handler.reportChange();
tracker.recordPassStop("loopA", passRuntime);
tracker.recordPassStart("loopA", false);
tracker.recordPassStop("loopA", passRuntime);
tracker.recordPassStart("noloopB", true);
handler.reportChange();
tracker.recordPassStop("noloopB", passRuntime);
tracker.recordPassStart("loopB", false);
tracker.recordPassStop("loopB", passRuntime);
tracker.recordPassStart("noloopB", true);
tracker.recordPassStop("noloopB", passRuntime);
int numRuns = tracker.getRuns();
assertEquals(numRuns, 7);
assertEquals(tracker.getRuntime(), numRuns * passRuntime);
assertEquals(tracker.getLoopRuns(), 3);
assertEquals(tracker.getChanges(), 4); /* reportChange was called 4 times */
assertEquals(tracker.getLoopChanges(), 1);
ImmutableMap<String, Stats> stats = tracker.getStats();
Stats st = stats.get("noloopA");
assertEquals(st.runs, 1);
assertEquals(st.runtime, passRuntime);
assertEquals(st.changes, 1);
st = stats.get("noloopB");
assertEquals(st.runs, 3);
assertEquals(st.runtime, 3 * passRuntime);
assertEquals(st.changes, 2);
st = stats.get("loopA");
assertEquals(st.runs, 2);
assertEquals(st.runtime, 2 * passRuntime);
assertEquals(st.changes, 1);
st = stats.get("loopB");
assertEquals(st.runs, 1);
assertEquals(st.runtime, passRuntime);
assertEquals(st.changes, 0);
}