| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include <stdio.h> | 5 #include <stdio.h> |
| 6 #include <map> | 6 #include <map> |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 | 10 |
| 11 bool inH = true; | 11 bool inH = true; |
| 12 struct H { | 12 struct H { |
| 13 H() { inH = false; tick_ = 0; bw_ = 0; d_bw_ = d_tick_ = 0; m_bw_ = 0; mem_ =
high_ = 0;} | 13 H() { inH = false; tick_ = 0; bw_ = 0; d_bw_ = d_tick_ = 0; m_bw_ = 0; mem_ =
high_ = 0;} |
| 14 ~H() { | 14 ~H() { |
| 15 inH = true; | 15 inH = true; |
| 16 int i = 0; | 16 int i = 0; |
| 17 for (M::iterator p = m_.begin(); p != m_.end(); ++p, ++i) { | 17 for (M::iterator p = m_.begin(); p != m_.end(); ++p, ++i) { |
| 18 size_t s = p->first; | 18 size_t s = p->first; |
| 19 LOG(INFO) << StringPrintf("%3d %8u: %8u %8u %8u %8u", i, s, | 19 LOG(INFO) << base::StringPrintf("%3d %8u: %8u %8u %8u %8u", i, s, |
| 20 m_[s], c_[s], h_[s], h_[s] * s); | 20 m_[s], c_[s], h_[s], h_[s] * s); |
| 21 } | 21 } |
| 22 LOG(INFO) << "Peak " << fmt(high_); | 22 LOG(INFO) << "Peak " << fmt(high_); |
| 23 } | 23 } |
| 24 | 24 |
| 25 std::string fmt(size_t s) { | 25 std::string fmt(size_t s) { |
| 26 if (s > 1000000000) return StringPrintf("%.3gG", s/(1000000000.0)); | 26 if (s > 1000000000) return base::StringPrintf("%.3gG", s/(1000000000.0)); |
| 27 if (s > 1000000) return StringPrintf("%.3gM", s/(1000000.)); | 27 if (s > 1000000) return base::StringPrintf("%.3gM", s/(1000000.)); |
| 28 if (s > 9999) return StringPrintf("%.3gk", s/(1000.)); | 28 if (s > 9999) return base::StringPrintf("%.3gk", s/(1000.)); |
| 29 return StringPrintf("%d", (int)s); | 29 return base::StringPrintf("%d", (int)s); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void tick(size_t w, char sign) { | 32 void tick(size_t w, char sign) { |
| 33 d_tick_ += 1; | 33 d_tick_ += 1; |
| 34 d_bw_ += w; | 34 d_bw_ += w; |
| 35 const size_t T = 4*4*1024; | 35 const size_t T = 4*4*1024; |
| 36 const size_t M = 4*1024*1024; | 36 const size_t M = 4*1024*1024; |
| 37 bool print = false; | 37 bool print = false; |
| 38 if (d_tick_ >= T) { | 38 if (d_tick_ >= T) { |
| 39 tick_ += (d_tick_/T)*T; | 39 tick_ += (d_tick_/T)*T; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 //printf("%u\n", s); | 117 //printf("%u\n", s); |
| 118 void *p = malloc(s); | 118 void *p = malloc(s); |
| 119 _H.add(s, p); | 119 _H.add(s, p); |
| 120 return p; | 120 return p; |
| 121 } | 121 } |
| 122 | 122 |
| 123 void operator delete(void *p) { | 123 void operator delete(void *p) { |
| 124 _H.sub(p); | 124 _H.sub(p); |
| 125 free(p); | 125 free(p); |
| 126 } | 126 } |
| OLD | NEW |