OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" |
| 6 #include "testing/gtest-support.h" |
| 7 |
| 8 namespace v8 { |
| 9 namespace internal { |
| 10 |
| 11 TEST(CompilerDispatcherTracerTest, EstimateZeroWithoutSamples) { |
| 12 CompilerDispatcherTracer tracer(nullptr); |
| 13 |
| 14 EXPECT_EQ(0.0, tracer.EstimatePrepareToParse()); |
| 15 EXPECT_EQ(0.0, tracer.EstimateParse(0)); |
| 16 EXPECT_EQ(0.0, tracer.EstimateParse(42)); |
| 17 EXPECT_EQ(0.0, tracer.EstimateFinalizeParsing()); |
| 18 EXPECT_EQ(0.0, tracer.EstimatePrepareToCompile()); |
| 19 EXPECT_EQ(0.0, tracer.EstimateCompile(0)); |
| 20 EXPECT_EQ(0.0, tracer.EstimateCompile(42)); |
| 21 EXPECT_EQ(0.0, tracer.EstimateFinalizeCompiling()); |
| 22 } |
| 23 |
| 24 TEST(CompilerDispatcherTracerTest, Average) { |
| 25 CompilerDispatcherTracer tracer(nullptr); |
| 26 |
| 27 EXPECT_EQ(0.0, tracer.EstimatePrepareToParse()); |
| 28 |
| 29 tracer.RecordPrepareToParse(1.0); |
| 30 tracer.RecordPrepareToParse(2.0); |
| 31 tracer.RecordPrepareToParse(3.0); |
| 32 |
| 33 EXPECT_EQ((1.0 + 2.0 + 3.0) / 3, tracer.EstimatePrepareToParse()); |
| 34 } |
| 35 |
| 36 TEST(CompilerDispatcherTracerTest, SizeBasedAverage) { |
| 37 CompilerDispatcherTracer tracer(nullptr); |
| 38 |
| 39 EXPECT_EQ(0.0, tracer.EstimatePrepareToParse()); |
| 40 |
| 41 // All three samples parse 100 units/ms. |
| 42 tracer.RecordParse(1.0, 100); |
| 43 tracer.RecordParse(2.0, 200); |
| 44 tracer.RecordParse(3.0, 300); |
| 45 |
| 46 EXPECT_EQ(1.0, tracer.EstimateParse(100)); |
| 47 EXPECT_EQ(5.0, tracer.EstimateParse(500)); |
| 48 } |
| 49 |
| 50 } // namespace internal |
| 51 } // namespace v8 |
OLD | NEW |