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

Unified Diff: runtime/vm/counters.cc

Issue 336683003: Light-weight stats counters for experiments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | « runtime/vm/counters.h ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/counters.cc
===================================================================
--- runtime/vm/counters.cc (revision 0)
+++ runtime/vm/counters.cc (revision 0)
@@ -0,0 +1,40 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "vm/counters.h"
+
+#include <string.h>
+#include <map>
Ivan Posva 2014/06/13 22:14:32 Please add a TODO to remove this.
koda 2014/06/16 17:12:48 Done.
+
+#include "platform/globals.h"
+#include "vm/os.h"
+
+namespace dart {
+
+struct CStrLess {
+ bool operator()(const char* a, const char* b) const {
+ return strcmp(a, b) < 0;
+ }
+};
+
+
+Counters::~Counters() {
+ if (collision_) {
+ OS::PrintErr("Counters table collision; increase Counters::kSize.");
+ return;
+ }
+ typedef std::map<const char*, int64_t, CStrLess> TotalsMap;
+ TotalsMap totals;
+ for (int i = 0; i < kSize; ++i) {
+ const Counter& counter = counters_[i];
+ if (counter.name != NULL) {
+ totals[counter.name] += counter.value;
+ }
+ }
+ for (TotalsMap::iterator it = totals.begin(); it != totals.end(); ++it) {
+ OS::PrintErr("%s: %" Pd64 "\n", it->first, it->second);
+ }
+}
+
+} // namespace dart
« no previous file with comments | « runtime/vm/counters.h ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698