Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1954)

Unified Diff: base/test/test_suite.cc

Issue 2131293002: Make all tests profilable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base_switches.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_suite.cc
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 81ea744e5088545126dd56bd9bc44dc37d50454f..512bde5810a349dc6cc2f8a3a39db86d8d28daf7 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -12,6 +12,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/debug/debugger.h"
+#include "base/debug/profiler.h"
#include "base/debug/stack_trace.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
@@ -92,6 +93,20 @@ class TestClientInitializer : public testing::EmptyTestEventListener {
DISALLOW_COPY_AND_ASSIGN(TestClientInitializer);
};
+std::string GetProfileName() {
+ static const char kDefaultProfileName[] = "test-profile-{pid}";
+ CR_DEFINE_STATIC_LOCAL(std::string, profile_name, ());
+ if (profile_name.empty()) {
+ const base::CommandLine& command_line =
+ *base::CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kProfilingFile))
+ profile_name = command_line.GetSwitchValueASCII(switches::kProfilingFile);
+ else
+ profile_name = std::string(kDefaultProfileName);
+ }
+ return profile_name;
+}
+
} // namespace
int RunUnitTestsUsingBaseTestSuite(int argc, char **argv) {
@@ -362,9 +377,13 @@ void TestSuite::Initialize() {
TestTimeouts::Initialize();
trace_to_file_.BeginTracingFromCommandLineOptions();
+
+ base::debug::StartProfiling(GetProfileName());
}
void TestSuite::Shutdown() {
+ base::debug::StopProfiling();
+
// Clear the FeatureList that was created by Initialize().
if (created_feature_list_)
FeatureList::ClearInstanceForTesting();
« no previous file with comments | « base/base_switches.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698