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

Side by Side Diff: runtime/vm/trace_buffer.h

Issue 50413003: TraceBuffer implementation with tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | « no previous file | runtime/vm/trace_buffer.cc » ('j') | runtime/vm/trace_buffer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_TRACE_BUFFER_H_
6 #define VM_TRACE_BUFFER_H_
7
8 #include "platform/assert.h"
9 #include "platform/globals.h"
10 #include "vm/json_stream.h"
11
12 namespace dart {
13
14 class JSONStream;
15
16 struct TraceBufferEntry {
17 double seconds;
18 char* message;
19 };
20
21 class TraceBuffer {
22 public:
23 static const intptr_t kDefaultCapacity = 1024;
24
25 explicit TraceBuffer(intptr_t capacity = kDefaultCapacity);
26 ~TraceBuffer();
27
28 void Clear();
29
30 // Internally message is copied.
31 void Trace(int64_t time, const char* message);
32 // Internally message is copied.
33 void Trace(const char* message);
34 void TraceF(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
35
36 void PrintToJSONStream(JSONStream* stream) const;
37
38 private:
39 void Init();
40 void Cleanup();
41 void Fill(TraceBufferEntry* entry, double seconds, char* msg);
42 void AppendTrace(int64_t time, char* message);
43
44 TraceBufferEntry* ring_;
45 intptr_t ring_capacity_;
srdjan 2013/11/07 22:53:00 const?
Cutch 2013/11/13 17:33:14 Done.
46 intptr_t ring_start_;
Ivan Posva 2013/11/07 22:36:28 Single index should suffice.
Cutch 2013/11/13 17:33:14 Done.
47 intptr_t ring_size_;
48
49 intptr_t RingIndex(intptr_t i) const {
50 return i % ring_capacity_;
51 }
52
53 DISALLOW_COPY_AND_ASSIGN(TraceBuffer);
54 };
55
56
57 } // namespace dart
58
59 #endif // VM_TRACE_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/trace_buffer.cc » ('j') | runtime/vm/trace_buffer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698