| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/nacl/renderer/histogram.h" | 5 #include "components/nacl/renderer/histogram.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 | 8 |
| 9 namespace nacl { | 9 namespace nacl { |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 if (sandbox_isa == "arm") | 79 if (sandbox_isa == "arm") |
| 80 os_arch = static_cast<NaClOSArch>(os_arch + 2); | 80 os_arch = static_cast<NaClOSArch>(os_arch + 2); |
| 81 if (sandbox_isa == "mips32") | 81 if (sandbox_isa == "mips32") |
| 82 os_arch = kNaClLinuxMips; | 82 os_arch = kNaClLinuxMips; |
| 83 | 83 |
| 84 HistogramEnumerate("NaCl.Client.OSArch", os_arch, kNaClOSArchMax); | 84 HistogramEnumerate("NaCl.Client.OSArch", os_arch, kNaClOSArchMax); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Records values up to 20 seconds. | 87 // Records values up to 20 seconds. |
| 88 // These constants MUST match those in | 88 // These constants MUST match those in |
| 89 // ppapi/native_client/src/trusted/plugin/plugin.cc | 89 // components/nacl/renderer/plugin/plugin.cc |
| 90 void HistogramTimeSmall(const std::string& name, int64_t sample) { | 90 void HistogramTimeSmall(const std::string& name, int64_t sample) { |
| 91 if (sample < 0) | 91 if (sample < 0) |
| 92 sample = 0; | 92 sample = 0; |
| 93 base::HistogramBase* counter = base::Histogram::FactoryTimeGet( | 93 base::HistogramBase* counter = base::Histogram::FactoryTimeGet( |
| 94 name, | 94 name, |
| 95 base::TimeDelta::FromMilliseconds(1), | 95 base::TimeDelta::FromMilliseconds(1), |
| 96 base::TimeDelta::FromMilliseconds(20000), | 96 base::TimeDelta::FromMilliseconds(20000), |
| 97 100, | 97 100, |
| 98 base::HistogramBase::kUmaTargetedHistogramFlag); | 98 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 99 if (counter) | 99 if (counter) |
| 100 counter->AddTime(base::TimeDelta::FromMilliseconds(sample)); | 100 counter->AddTime(base::TimeDelta::FromMilliseconds(sample)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Records values up to 3 minutes, 20 seconds. | 103 // Records values up to 3 minutes, 20 seconds. |
| 104 // These constants MUST match those in | 104 // These constants MUST match those in |
| 105 // ppapi/native_client/src/trusted/plugin/plugin.cc | 105 // components/nacl/renderer/plugin/plugin.cc |
| 106 void HistogramTimeMedium(const std::string& name, int64_t sample) { | 106 void HistogramTimeMedium(const std::string& name, int64_t sample) { |
| 107 if (sample < 0) | 107 if (sample < 0) |
| 108 sample = 0; | 108 sample = 0; |
| 109 base::HistogramBase* counter = base::Histogram::FactoryTimeGet( | 109 base::HistogramBase* counter = base::Histogram::FactoryTimeGet( |
| 110 name, | 110 name, |
| 111 base::TimeDelta::FromMilliseconds(10), | 111 base::TimeDelta::FromMilliseconds(10), |
| 112 base::TimeDelta::FromMilliseconds(200000), | 112 base::TimeDelta::FromMilliseconds(200000), |
| 113 100, | 113 100, |
| 114 base::HistogramBase::kUmaTargetedHistogramFlag); | 114 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 115 if (counter) | 115 if (counter) |
| 116 counter->AddTime(base::TimeDelta::FromMilliseconds(sample)); | 116 counter->AddTime(base::TimeDelta::FromMilliseconds(sample)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Records values up to 33 minutes. | 119 // Records values up to 33 minutes. |
| 120 // These constants MUST match those in | 120 // These constants MUST match those in |
| 121 // ppapi/native_client/src/trusted/plugin/plugin.cc | 121 // components/nacl/renderer/plugin/plugin.cc |
| 122 void HistogramTimeLarge(const std::string& name, int64_t sample) { | 122 void HistogramTimeLarge(const std::string& name, int64_t sample) { |
| 123 if (sample < 0) | 123 if (sample < 0) |
| 124 sample = 0; | 124 sample = 0; |
| 125 base::HistogramBase* counter = base::Histogram::FactoryTimeGet( | 125 base::HistogramBase* counter = base::Histogram::FactoryTimeGet( |
| 126 name, | 126 name, |
| 127 base::TimeDelta::FromMilliseconds(100), | 127 base::TimeDelta::FromMilliseconds(100), |
| 128 base::TimeDelta::FromMilliseconds(2000000), | 128 base::TimeDelta::FromMilliseconds(2000000), |
| 129 100, | 129 100, |
| 130 base::HistogramBase::kUmaTargetedHistogramFlag); | 130 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 131 if (counter) | 131 if (counter) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 static const double kMaxRate = 30 * 1000.0; // max of 30MB/sec. | 198 static const double kMaxRate = 30 * 1000.0; // max of 30MB/sec. |
| 199 int32_t rate = std::min(kb / (us / 1000000.0), kMaxRate); | 199 int32_t rate = std::min(kb / (us / 1000000.0), kMaxRate); |
| 200 HistogramCustomCounts(name, | 200 HistogramCustomCounts(name, |
| 201 rate, | 201 rate, |
| 202 1, | 202 1, |
| 203 30 * 1000, // max of 30 MB/sec. | 203 30 * 1000, // max of 30 MB/sec. |
| 204 100); | 204 100); |
| 205 } | 205 } |
| 206 | 206 |
| 207 } // namespace nacl | 207 } // namespace nacl |
| OLD | NEW |