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

Side by Side Diff: base/debug/profiler.cc

Issue 6250070: Added command line switches and UI (controlled via a build option) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review concerns Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/debug/profiler.h ('k') | build/common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 "base/debug/profiler.h"
6
7 #include <string>
8
9 #include "base/process_util.h"
10 #include "base/string_util.h"
11
12 #if defined(ENABLE_PROFILING) && !defined(NO_TCMALLOC)
13 #include "third_party/tcmalloc/chromium/src/google/profiler.h"
14 #endif
15
16 namespace base {
17 namespace debug {
18
19 #if defined(ENABLE_PROFILING) && !defined(NO_TCMALLOC)
20
21 static int profile_count = 0;
22
23 void StartProfiling(const std::string& name) {
24 ++profile_count;
25 std::string full_name(name);
26 std::string pid = StringPrintf("%d", GetCurrentProcId());
27 std::string count = StringPrintf("%d", profile_count);
28 ReplaceSubstringsAfterOffset(&full_name, 0, "{pid}", pid.c_str());
29 ReplaceSubstringsAfterOffset(&full_name, 0, "{count}", count);
30 ProfilerStart(full_name.c_str());
31 }
32
33 void StopProfiling() {
34 ProfilerFlush();
35 ProfilerStop();
36 }
37
38 void FlushProfiling() {
39 ProfilerFlush();
40 }
41
42 bool BeingProfiled() {
43 return ProfilingIsEnabledForAllThreads();
44 }
45
46 #else
47
48 void StartProfiling(const std::string& name) {
49 }
50
51 void StopProfiling() {
52 }
53
54 void FlushProfiling() {
55 }
56
57 bool BeingProfiled() {
58 return false;
59 }
60
61 #endif
62
63 } // namespace debug
64 } // namespace base
65
OLDNEW
« no previous file with comments | « base/debug/profiler.h ('k') | build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698