Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Unified Diff: test/unittests/compiler-dispatcher/compiler-dispatcher-tracer-unittest.cc

Issue 2413243002: Introduce a CompilerDispatcherTracer and track how long jobs take (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/unittests/compiler-dispatcher/compiler-dispatcher-tracer-unittest.cc
diff --git a/test/unittests/compiler-dispatcher/compiler-dispatcher-tracer-unittest.cc b/test/unittests/compiler-dispatcher/compiler-dispatcher-tracer-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4e1c7fd987f2047e5498532069af126701e522dd
--- /dev/null
+++ b/test/unittests/compiler-dispatcher/compiler-dispatcher-tracer-unittest.cc
@@ -0,0 +1,51 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/compiler-dispatcher/compiler-dispatcher-tracer.h"
+#include "testing/gtest-support.h"
+
+namespace v8 {
+namespace internal {
+
+TEST(CompilerDispatcherTracerTest, EstimateZeroWithoutSamples) {
+ CompilerDispatcherTracer tracer(nullptr);
+
+ EXPECT_EQ(0.0, tracer.EstimatePrepareToParse());
+ EXPECT_EQ(0.0, tracer.EstimateParse(0));
+ EXPECT_EQ(0.0, tracer.EstimateParse(42));
+ EXPECT_EQ(0.0, tracer.EstimateFinalizeParsing());
+ EXPECT_EQ(0.0, tracer.EstimatePrepareToCompile());
+ EXPECT_EQ(0.0, tracer.EstimateCompile(0));
+ EXPECT_EQ(0.0, tracer.EstimateCompile(42));
+ EXPECT_EQ(0.0, tracer.EstimateFinalizeCompiling());
+}
+
+TEST(CompilerDispatcherTracerTest, Average) {
+ CompilerDispatcherTracer tracer(nullptr);
+
+ EXPECT_EQ(0.0, tracer.EstimatePrepareToParse());
+
+ tracer.RecordPrepareToParse(1.0);
+ tracer.RecordPrepareToParse(2.0);
+ tracer.RecordPrepareToParse(3.0);
+
+ EXPECT_EQ((1.0 + 2.0 + 3.0) / 3, tracer.EstimatePrepareToParse());
+}
+
+TEST(CompilerDispatcherTracerTest, SizeBasedAverage) {
+ CompilerDispatcherTracer tracer(nullptr);
+
+ EXPECT_EQ(0.0, tracer.EstimatePrepareToParse());
+
+ // All three samples parse 100 units/ms.
+ tracer.RecordParse(1.0, 100);
+ tracer.RecordParse(2.0, 200);
+ tracer.RecordParse(3.0, 300);
+
+ EXPECT_EQ(1.0, tracer.EstimateParse(100));
+ EXPECT_EQ(5.0, tracer.EstimateParse(500));
+}
+
+} // namespace internal
+} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698