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

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

Issue 1343253002: - Remove unused Counters class from isolate. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 | runtime/vm/counters.cc » ('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) 2014, 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_COUNTERS_H_
6 #define VM_COUNTERS_H_
7
8 #include "platform/assert.h"
9
10 namespace dart {
11
12 struct Counter {
13 Counter() : name(NULL), value(0) {}
14 const char* name;
15 int64_t value;
16 };
17
18
19 // Light-weight stats counters for temporary experiments/debugging.
20 // A single statement is enough to add a counter:
21 // ...
22 // Isolate::Current()->counters()->Increment("allocated", size_in_bytes);
23 // ...
24 class Counters {
25 public:
26 Counters() : collision_(false) {}
27
28 // Adds 'delta' to the named counter. 'name' must be a literal string.
29 void Increment(const char* name, int64_t delta) {
30 Counter& counter =
31 counters_[reinterpret_cast<uword>(name) & (kSize - 1)];
32 if (counter.name != name && counter.name != NULL) {
33 collision_ = true;
34 }
35 counter.name = name;
36 counter.value += delta;
37 }
38
39 // Prints all counters to stderr.
40 ~Counters();
41
42 private:
43 enum { kSize = 1024 };
44 COMPILE_ASSERT((0 == (kSize & (kSize - 1)))); // kSize is a power of 2.
45 Counter counters_[kSize];
46 bool collision_;
47 };
48
49 } // namespace dart
50
51 #endif // VM_COUNTERS_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/counters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698