v8/test/unittests/compiler-dispatcher/compiler-dispatcher-tracer-unittest.cc
Mythri 3e47cb87d6 [Turbofan] Use bytecode size for inlining heuristics.
Inlining heuristics in Turbofan used ast node count. Bytecode size
is a better approximation of the size of the graph than the
ast node count. This cl changes the heuristics to use the bytecode
size instead. Also removing the ast_node_count filed in the shared
function info. It was used only for the inlining heuristics.

Also removed the max_inlined_source_size flag which is no longer used.

Bug: 
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: I8a2d2509c8e8d2779b33b817bb217de203d54ec3
Reviewed-on: https://chromium-review.googlesource.com/570055
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46771}
2017-07-19 17:01:55 +00:00

52 lines
1.6 KiB
C++

// 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, EstimateWithoutSamples) {
CompilerDispatcherTracer tracer(nullptr);
EXPECT_EQ(0.0, tracer.EstimatePrepareToParseInMs());
EXPECT_EQ(1.0, tracer.EstimateParseInMs(0));
EXPECT_EQ(1.0, tracer.EstimateParseInMs(42));
EXPECT_EQ(0.0, tracer.EstimateFinalizeParsingInMs());
EXPECT_EQ(0.0, tracer.EstimatePrepareToCompileInMs());
EXPECT_EQ(0.0, tracer.EstimateCompileInMs());
EXPECT_EQ(0.0, tracer.EstimateCompileInMs());
EXPECT_EQ(0.0, tracer.EstimateFinalizeCompilingInMs());
}
TEST(CompilerDispatcherTracerTest, Average) {
CompilerDispatcherTracer tracer(nullptr);
EXPECT_EQ(0.0, tracer.EstimatePrepareToParseInMs());
tracer.RecordPrepareToParse(1.0);
tracer.RecordPrepareToParse(2.0);
tracer.RecordPrepareToParse(3.0);
EXPECT_EQ((1.0 + 2.0 + 3.0) / 3, tracer.EstimatePrepareToParseInMs());
}
TEST(CompilerDispatcherTracerTest, SizeBasedAverage) {
CompilerDispatcherTracer tracer(nullptr);
EXPECT_EQ(1.0, tracer.EstimateParseInMs(100));
// 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.EstimateParseInMs(100));
EXPECT_EQ(5.0, tracer.EstimateParseInMs(500));
}
} // namespace internal
} // namespace v8