2016-10-14 08:12:16 +00:00
|
|
|
// 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 {
|
|
|
|
|
2016-12-16 14:40:32 +00:00
|
|
|
TEST(CompilerDispatcherTracerTest, EstimateWithoutSamples) {
|
2016-10-14 08:12:16 +00:00
|
|
|
CompilerDispatcherTracer tracer(nullptr);
|
|
|
|
|
2017-11-16 12:58:16 +00:00
|
|
|
EXPECT_EQ(0.0, tracer.EstimatePrepareInMs());
|
|
|
|
EXPECT_EQ(1.0, tracer.EstimateCompileInMs(1));
|
|
|
|
EXPECT_EQ(1.0, tracer.EstimateCompileInMs(42));
|
|
|
|
EXPECT_EQ(0.0, tracer.EstimateFinalizeInMs());
|
2016-10-14 08:12:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CompilerDispatcherTracerTest, Average) {
|
|
|
|
CompilerDispatcherTracer tracer(nullptr);
|
|
|
|
|
2017-11-16 12:58:16 +00:00
|
|
|
EXPECT_EQ(0.0, tracer.EstimatePrepareInMs());
|
2016-10-14 08:12:16 +00:00
|
|
|
|
2017-11-16 12:58:16 +00:00
|
|
|
tracer.RecordPrepare(1.0);
|
|
|
|
tracer.RecordPrepare(2.0);
|
|
|
|
tracer.RecordPrepare(3.0);
|
2016-10-14 08:12:16 +00:00
|
|
|
|
2017-11-16 12:58:16 +00:00
|
|
|
EXPECT_EQ((1.0 + 2.0 + 3.0) / 3, tracer.EstimatePrepareInMs());
|
2016-10-14 08:12:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CompilerDispatcherTracerTest, SizeBasedAverage) {
|
|
|
|
CompilerDispatcherTracer tracer(nullptr);
|
|
|
|
|
2017-11-16 12:58:16 +00:00
|
|
|
EXPECT_EQ(1.0, tracer.EstimateCompileInMs(100));
|
2016-10-14 08:12:16 +00:00
|
|
|
|
|
|
|
// All three samples parse 100 units/ms.
|
2017-11-16 12:58:16 +00:00
|
|
|
tracer.RecordCompile(1.0, 100);
|
|
|
|
tracer.RecordCompile(2.0, 200);
|
|
|
|
tracer.RecordCompile(3.0, 300);
|
2016-10-14 08:12:16 +00:00
|
|
|
|
2017-11-16 12:58:16 +00:00
|
|
|
EXPECT_EQ(1.0, tracer.EstimateCompileInMs(100));
|
|
|
|
EXPECT_EQ(5.0, tracer.EstimateCompileInMs(500));
|
2016-10-14 08:12:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|