1 // Copyright 2017 The Chromium 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 "third_party/blink/renderer/platform/testing/blink_perf_test_suite.h" 6 7 #include "base/command_line.h" 8 #include "base/debug/debugger.h" 9 #include "base/files/file_path.h" 10 #include "base/path_service.h" 11 #include "base/process/launch.h" 12 #include "base/strings/string_util.h" 13 #include "base/test/perf_log.h" 14 #include "build/build_config.h" 15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "third_party/blink/renderer/platform/wtf/allocator/partitions.h" 17 #include "third_party/blink/renderer/platform/wtf/wtf.h" 18 19 namespace blink { 20 BlinkPerfTestSuite(int argc,char ** argv)21BlinkPerfTestSuite::BlinkPerfTestSuite(int argc, char** argv) 22 : base::TestSuite(argc, argv), env(argc, argv) {} 23 Initialize()24void BlinkPerfTestSuite::Initialize() { 25 TestSuite::Initialize(); 26 27 // Initialize the perf timer log 28 base::FilePath log_path = 29 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath("log-file"); 30 if (log_path.empty()) { 31 base::PathService::Get(base::FILE_EXE, &log_path); 32 #if defined(OS_ANDROID) 33 base::FilePath tmp_dir; 34 base::PathService::Get(base::DIR_CACHE, &tmp_dir); 35 log_path = tmp_dir.Append(log_path.BaseName()); 36 #endif 37 log_path = log_path.ReplaceExtension(FILE_PATH_LITERAL("log")); 38 log_path = log_path.InsertBeforeExtension(FILE_PATH_LITERAL("_perf")); 39 } 40 ASSERT_TRUE(base::InitPerfLog(log_path)); 41 42 // Raise to high priority to have more precise measurements. Since we don't 43 // aim at 1% precision, it is not necessary to run at realtime level. 44 if (!base::debug::BeingDebugged()) 45 base::RaiseProcessToHighPriority(); 46 } 47 Shutdown()48void BlinkPerfTestSuite::Shutdown() { 49 TestSuite::Shutdown(); 50 base::FinalizePerfLog(); 51 } 52 53 } // namespace blink 54