Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #include "vm/counters.h" | |
| 6 | |
| 7 #include <string.h> | |
| 8 #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.
| |
| 9 | |
| 10 #include "platform/globals.h" | |
| 11 #include "vm/os.h" | |
| 12 | |
| 13 namespace dart { | |
| 14 | |
| 15 struct CStrLess { | |
| 16 bool operator()(const char* a, const char* b) const { | |
| 17 return strcmp(a, b) < 0; | |
| 18 } | |
| 19 }; | |
| 20 | |
| 21 | |
| 22 Counters::~Counters() { | |
| 23 if (collision_) { | |
| 24 OS::PrintErr("Counters table collision; increase Counters::kSize."); | |
| 25 return; | |
| 26 } | |
| 27 typedef std::map<const char*, int64_t, CStrLess> TotalsMap; | |
| 28 TotalsMap totals; | |
| 29 for (int i = 0; i < kSize; ++i) { | |
| 30 const Counter& counter = counters_[i]; | |
| 31 if (counter.name != NULL) { | |
| 32 totals[counter.name] += counter.value; | |
| 33 } | |
| 34 } | |
| 35 for (TotalsMap::iterator it = totals.begin(); it != totals.end(); ++it) { | |
| 36 OS::PrintErr("%s: %" Pd64 "\n", it->first, it->second); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 } // namespace dart | |
| OLD | NEW |