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