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

Side by Side Diff: base/trace_event.h

Issue 174118: Don't compile with TraceLog support on by default. (Closed)
Patch Set: Created 11 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Trace events to track application performance. Events consist of a name 5 // Trace events to track application performance. Events consist of a name
6 // a type (BEGIN, END or INSTANT), a tracking id and extra string data. 6 // a type (BEGIN, END or INSTANT), a tracking id and extra string data.
7 // In addition, the current process id, thread id, a timestamp down to the 7 // In addition, the current process id, thread id, a timestamp down to the
8 // microsecond and a file and line number of the calling location. 8 // microsecond and a file and line number of the calling location.
9 // 9 //
10 // The current implementation logs these events into a log file of the form 10 // The current implementation logs these events into a log file of the form
(...skipping 11 matching lines...) Expand all
22 #endif 22 #endif
23 23
24 #include <string> 24 #include <string>
25 25
26 #include "base/lock.h" 26 #include "base/lock.h"
27 #include "base/scoped_ptr.h" 27 #include "base/scoped_ptr.h"
28 #include "base/singleton.h" 28 #include "base/singleton.h"
29 #include "base/time.h" 29 #include "base/time.h"
30 #include "base/timer.h" 30 #include "base/timer.h"
31 31
32 #if 1 // Set to 0 to compile with tracing.
Mark Mentovai 2009/08/20 01:44:34 Can we make this something like #ifndef ENABLE_TRA
33 #define TRACE_EVENT_BEGIN(name, id, extra) ((void) 0)
34 #define TRACE_EVENT_END(name, id, extra) ((void) 0)
35 #define TRACE_EVENT_INSTANT(name, id, extra) ((void) 0)
36
37 #else
32 // Use the following macros rather than using the TraceLog class directly as the 38 // Use the following macros rather than using the TraceLog class directly as the
33 // underlying implementation may change in the future. Here's a sample usage: 39 // underlying implementation may change in the future. Here's a sample usage:
34 // TRACE_EVENT_BEGIN("v8.run", documentId, scriptLocation); 40 // TRACE_EVENT_BEGIN("v8.run", documentId, scriptLocation);
35 // RunScript(script); 41 // RunScript(script);
36 // TRACE_EVENT_END("v8.run", documentId, scriptLocation); 42 // TRACE_EVENT_END("v8.run", documentId, scriptLocation);
37 43
38 // Record that an event (of name, id) has begun. All BEGIN events should have 44 // Record that an event (of name, id) has begun. All BEGIN events should have
39 // corresponding END events with a matching (name, id). 45 // corresponding END events with a matching (name, id).
40 #define TRACE_EVENT_BEGIN(name, id, extra) \ 46 #define TRACE_EVENT_BEGIN(name, id, extra) \
41 Singleton<base::TraceLog>::get()->Trace(name, \ 47 Singleton<base::TraceLog>::get()->Trace(name, \
(...skipping 14 matching lines...) Expand all
56 __LINE__) 62 __LINE__)
57 63
58 // Record that an event (of name, id) with no duration has happened. 64 // Record that an event (of name, id) with no duration has happened.
59 #define TRACE_EVENT_INSTANT(name, id, extra) \ 65 #define TRACE_EVENT_INSTANT(name, id, extra) \
60 Singleton<base::TraceLog>::get()->Trace(name, \ 66 Singleton<base::TraceLog>::get()->Trace(name, \
61 base::TraceLog::EVENT_INSTANT, \ 67 base::TraceLog::EVENT_INSTANT, \
62 reinterpret_cast<const void*>(id), \ 68 reinterpret_cast<const void*>(id), \
63 extra, \ 69 extra, \
64 __FILE__, \ 70 __FILE__, \
65 __LINE__) 71 __LINE__)
72 #endif
Mark Mentovai 2009/08/20 01:44:34 Put a comment saying what you're ending, whatever
66 73
67 namespace base { 74 namespace base {
68 class ProcessMetrics; 75 class ProcessMetrics;
69 } 76 }
70 77
71 namespace base { 78 namespace base {
72 79
73 class TraceLog { 80 class TraceLog {
74 public: 81 public:
75 enum EventType { 82 enum EventType {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 FILE* log_file_; 124 FILE* log_file_;
118 Lock file_lock_; 125 Lock file_lock_;
119 TimeTicks trace_start_time_; 126 TimeTicks trace_start_time_;
120 scoped_ptr<base::ProcessMetrics> process_metrics_; 127 scoped_ptr<base::ProcessMetrics> process_metrics_;
121 RepeatingTimer<TraceLog> timer_; 128 RepeatingTimer<TraceLog> timer_;
122 }; 129 };
123 130
124 } // namespace base 131 } // namespace base
125 132
126 #endif // BASE_TRACE_EVENT_H_ 133 #endif // BASE_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698