Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "base/metrics/sparse_histogram.h" |
| 6 | |
danakj | 0c8d4aa | 2015-11-25 05:29:58 | [diff] [blame] | 7 | #include <utility> |
| 8 | |
Hans Wennborg | 9f3bb63d | 2020-04-21 11:12:38 | [diff] [blame] | 9 | #include "base/logging.h" |
dcheng | 093de9b | 2016-04-04 21:25:51 | [diff] [blame] | 10 | #include "base/memory/ptr_util.h" |
Gayane Petrosyan | 5745ac6 | 2018-03-23 01:45:24 | [diff] [blame] | 11 | #include "base/metrics/dummy_histogram.h" |
Alexei Svitkine | b49c09f | 2024-05-24 16:22:35 | [diff] [blame] | 12 | #include "base/metrics/histogram_functions.h" |
bcwhite | b036e432 | 2015-12-10 18:36:34 | [diff] [blame] | 13 | #include "base/metrics/metrics_hashes.h" |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 14 | #include "base/metrics/persistent_histogram_allocator.h" |
| 15 | #include "base/metrics/persistent_sample_map.h" |
[email protected] | 877ef56 | 2012-10-20 02:56:18 | [diff] [blame] | 16 | #include "base/metrics/sample_map.h" |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 17 | #include "base/metrics/statistics_recorder.h" |
David Sanders | 83f8ae4 | 2022-04-04 23:15:39 | [diff] [blame] | 18 | #include "base/notreached.h" |
[email protected] | c50c21d | 2013-01-11 21:52:44 | [diff] [blame] | 19 | #include "base/pickle.h" |
Jun Kokatsu | 505af9f | 2020-05-05 11:59:47 | [diff] [blame] | 20 | #include "base/strings/utf_string_conversions.h" |
[email protected] | b4af2ec | 2012-10-05 21:29:44 | [diff] [blame] | 21 | #include "base/synchronization/lock.h" |
Jun Kokatsu | 505af9f | 2020-05-05 11:59:47 | [diff] [blame] | 22 | #include "base/values.h" |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 23 | |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 24 | namespace base { |
| 25 | |
Ramon Cano Aparicio | b2cba0f | 2025-01-22 21:26:10 | [diff] [blame] | 26 | typedef HistogramBase::Count32 Count32; |
[email protected] | b4af2ec | 2012-10-05 21:29:44 | [diff] [blame] | 27 | |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 28 | // static |
Alexei Svitkine | 784ce69 | 2024-05-24 16:19:24 | [diff] [blame] | 29 | HistogramBase* SparseHistogram::FactoryGet(std::string_view name, |
avi | 9b6f4293 | 2015-12-26 22:15:14 | [diff] [blame] | 30 | int32_t flags) { |
Ramon Cano Aparicio | 901ec6c | 2025-04-22 14:30:45 | [diff] [blame] | 31 | uint64_t name_hash = HashMetricName(name); |
| 32 | HistogramBase* histogram = StatisticsRecorder::FindHistogram(name_hash, name); |
[email protected] | cc7dec21 | 2013-03-01 03:53:25 | [diff] [blame] | 33 | if (!histogram) { |
Ramon Cano Aparicio | 901ec6c | 2025-04-22 14:30:45 | [diff] [blame] | 34 | bool should_record = StatisticsRecorder::ShouldRecordHistogram( |
| 35 | ParseMetricHashTo32Bits(name_hash)); |
Alexei Svitkine | b49c09f | 2024-05-24 16:22:35 | [diff] [blame] | 36 | if (!should_record) { |
Gayane Petrosyan | 5745ac6 | 2018-03-23 01:45:24 | [diff] [blame] | 37 | return DummyHistogram::GetInstance(); |
Alexei Svitkine | b49c09f | 2024-05-24 16:22:35 | [diff] [blame] | 38 | } |
| 39 | // Try to create the histogram using a "persistent" allocator. If the |
| 40 | // allocator doesn't exist or if allocating from it fails, code below will |
| 41 | // allocate the histogram from the process heap. |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 42 | PersistentMemoryAllocator::Reference histogram_ref = 0; |
dcheng | 093de9b | 2016-04-04 21:25:51 | [diff] [blame] | 43 | std::unique_ptr<HistogramBase> tentative_histogram; |
bcwhite | 5e748c6 | 2016-04-06 02:03:53 | [diff] [blame] | 44 | PersistentHistogramAllocator* allocator = GlobalHistogramAllocator::Get(); |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 45 | if (allocator) { |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 46 | tentative_histogram = allocator->AllocateHistogram( |
Ramon Cano Aparicio | eb4e315 | 2025-05-09 14:26:57 | [diff] [blame] | 47 | SPARSE_HISTOGRAM, name, name_hash, /*minimum=*/0, /*maximum=*/0, |
| 48 | /*bucket_ranges=*/nullptr, flags, &histogram_ref); |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | // Handle the case where no persistent allocator is present or the |
| 52 | // persistent allocation fails (perhaps because it is full). |
| 53 | if (!tentative_histogram) { |
| 54 | DCHECK(!histogram_ref); // Should never have been set. |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 55 | flags &= ~HistogramBase::kIsPersistent; |
Ramon Cano Aparicio | eb4e315 | 2025-05-09 14:26:57 | [diff] [blame] | 56 | tentative_histogram.reset( |
| 57 | new SparseHistogram(GetPermanentName(name), name_hash)); |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 58 | tentative_histogram->SetFlags(flags); |
| 59 | } |
| 60 | |
| 61 | // Register this histogram with the StatisticsRecorder. Keep a copy of |
| 62 | // the pointer value to tell later whether the locally created histogram |
| 63 | // was registered or deleted. The type is "void" because it could point |
| 64 | // to released memory after the following line. |
| 65 | const void* tentative_histogram_ptr = tentative_histogram.get(); |
| 66 | histogram = StatisticsRecorder::RegisterOrDeleteDuplicate( |
| 67 | tentative_histogram.release()); |
| 68 | |
| 69 | // Persistent histograms need some follow-up processing. |
| 70 | if (histogram_ref) { |
| 71 | allocator->FinalizeHistogram(histogram_ref, |
| 72 | histogram == tentative_histogram_ptr); |
| 73 | } |
[email protected] | cc7dec21 | 2013-03-01 03:53:25 | [diff] [blame] | 74 | } |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 75 | |
Alexei Svitkine | b49c09f | 2024-05-24 16:22:35 | [diff] [blame] | 76 | if (histogram->GetHistogramType() != SPARSE_HISTOGRAM) { |
| 77 | // The type does not match the existing histogram. This can come about if an |
| 78 | // extension updates in the middle of a Chrome run or simply by bad code |
| 79 | // within Chrome itself. We can't return null since calling code does not |
| 80 | // expect it, so return a dummy instance and log the name hash. |
| 81 | // |
| 82 | // Note: Theoretically the below line could be re-entrant if something has |
| 83 | // gone very wrong, but crashing w/ an infinite recursion seems OK then. |
| 84 | UmaHistogramSparse("Histogram.MismatchedConstructionArguments", |
Ramon Cano Aparicio | 901ec6c | 2025-04-22 14:30:45 | [diff] [blame] | 85 | static_cast<Sample32>(name_hash)); |
Alexei Svitkine | b49c09f | 2024-05-24 16:22:35 | [diff] [blame] | 86 | DLOG(ERROR) << "Histogram " << name << " has a mismatched type"; |
| 87 | return DummyHistogram::GetInstance(); |
| 88 | } |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 89 | return histogram; |
| 90 | } |
| 91 | |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 92 | // static |
dcheng | 093de9b | 2016-04-04 21:25:51 | [diff] [blame] | 93 | std::unique_ptr<HistogramBase> SparseHistogram::PersistentCreate( |
bcwhite | b0bb919 | 2016-04-18 01:33:10 | [diff] [blame] | 94 | PersistentHistogramAllocator* allocator, |
Roger McFarlane | 8952859 | 2025-02-20 20:50:27 | [diff] [blame] | 95 | DurableStringView durable_name, |
Ramon Cano Aparicio | eb4e315 | 2025-05-09 14:26:57 | [diff] [blame] | 96 | uint64_t name_hash, |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 97 | HistogramSamples::Metadata* meta, |
| 98 | HistogramSamples::Metadata* logged_meta) { |
Ramon Cano Aparicio | eb4e315 | 2025-05-09 14:26:57 | [diff] [blame] | 99 | return WrapUnique(new SparseHistogram(allocator, durable_name, name_hash, |
| 100 | meta, logged_meta)); |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 101 | } |
| 102 | |
Chris Watkins | bb7211c | 2017-11-29 07:16:38 | [diff] [blame] | 103 | SparseHistogram::~SparseHistogram() = default; |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 104 | |
bcwhite | b036e432 | 2015-12-10 18:36:34 | [diff] [blame] | 105 | uint64_t SparseHistogram::name_hash() const { |
altimin | 498c838 | 2017-05-12 17:49:18 | [diff] [blame] | 106 | return unlogged_samples_->id(); |
bcwhite | b036e432 | 2015-12-10 18:36:34 | [diff] [blame] | 107 | } |
| 108 | |
[email protected] | 07c0240 | 2012-10-31 06:20:25 | [diff] [blame] | 109 | HistogramType SparseHistogram::GetHistogramType() const { |
| 110 | return SPARSE_HISTOGRAM; |
| 111 | } |
| 112 | |
[email protected] | 15ce384 | 2013-06-27 14:38:45 | [diff] [blame] | 113 | bool SparseHistogram::HasConstructionArguments( |
Ramon Cano Aparicio | 79e0664 | 2025-01-09 19:10:22 | [diff] [blame] | 114 | Sample32 expected_minimum, |
| 115 | Sample32 expected_maximum, |
Peter Kasting | fc94f506 | 2022-06-08 16:41:45 | [diff] [blame] | 116 | size_t expected_bucket_count) const { |
[email protected] | abae9b02 | 2012-10-24 08:18:52 | [diff] [blame] | 117 | // SparseHistogram never has min/max/bucket_count limit. |
| 118 | return false; |
| 119 | } |
| 120 | |
Ramon Cano Aparicio | 79e0664 | 2025-01-09 19:10:22 | [diff] [blame] | 121 | void SparseHistogram::Add(Sample32 value) { |
amohammadkhan | 6779b5c3 | 2015-08-05 20:31:11 | [diff] [blame] | 122 | AddCount(value, 1); |
| 123 | } |
| 124 | |
Ramon Cano Aparicio | 79e0664 | 2025-01-09 19:10:22 | [diff] [blame] | 125 | void SparseHistogram::AddCount(Sample32 value, int count) { |
amohammadkhan | 6779b5c3 | 2015-08-05 20:31:11 | [diff] [blame] | 126 | if (count <= 0) { |
Peter Boström | de57333 | 2024-08-26 20:42:45 | [diff] [blame] | 127 | NOTREACHED(); |
amohammadkhan | 6779b5c3 | 2015-08-05 20:31:11 | [diff] [blame] | 128 | } |
simonhatch | df5a814 | 2015-07-15 22:22:57 | [diff] [blame] | 129 | { |
| 130 | base::AutoLock auto_lock(lock_); |
altimin | 498c838 | 2017-05-12 17:49:18 | [diff] [blame] | 131 | unlogged_samples_->Accumulate(value, count); |
simonhatch | df5a814 | 2015-07-15 22:22:57 | [diff] [blame] | 132 | } |
| 133 | |
Peter Kasting | fa48899 | 2024-08-06 07:48:14 | [diff] [blame] | 134 | if (StatisticsRecorder::have_active_callbacks()) [[unlikely]] { |
Shakti Sahu | e0e07a0e | 2021-06-06 00:07:52 | [diff] [blame] | 135 | FindAndRunCallbacks(value); |
Peter Kasting | fa48899 | 2024-08-06 07:48:14 | [diff] [blame] | 136 | } |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 137 | } |
| 138 | |
dcheng | 093de9b | 2016-04-04 21:25:51 | [diff] [blame] | 139 | std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { |
| 140 | std::unique_ptr<SampleMap> snapshot(new SampleMap(name_hash())); |
[email protected] | b4af2ec | 2012-10-05 21:29:44 | [diff] [blame] | 141 | |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 142 | base::AutoLock auto_lock(lock_); |
altimin | 498c838 | 2017-05-12 17:49:18 | [diff] [blame] | 143 | snapshot->Add(*unlogged_samples_); |
| 144 | snapshot->Add(*logged_samples_); |
danakj | 0c8d4aa | 2015-11-25 05:29:58 | [diff] [blame] | 145 | return std::move(snapshot); |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 146 | } |
| 147 | |
Luc Nguyen | e01c675 | 2022-12-01 18:40:15 | [diff] [blame] | 148 | std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotUnloggedSamples() |
| 149 | const { |
| 150 | std::unique_ptr<SampleMap> snapshot(new SampleMap(name_hash())); |
| 151 | |
| 152 | base::AutoLock auto_lock(lock_); |
| 153 | snapshot->Add(*unlogged_samples_); |
| 154 | |
| 155 | return std::move(snapshot); |
| 156 | } |
| 157 | |
| 158 | void SparseHistogram::MarkSamplesAsLogged(const HistogramSamples& samples) { |
| 159 | DCHECK(!final_delta_created_); |
| 160 | |
| 161 | base::AutoLock auto_lock(lock_); |
| 162 | unlogged_samples_->Subtract(samples); |
| 163 | logged_samples_->Add(samples); |
| 164 | } |
| 165 | |
dcheng | 093de9b | 2016-04-04 21:25:51 | [diff] [blame] | 166 | std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotDelta() { |
bcwhite | 65e57d0 | 2016-05-13 14:39:40 | [diff] [blame] | 167 | DCHECK(!final_delta_created_); |
| 168 | |
Luc Nguyen | 257ecb0 | 2023-04-11 21:09:41 | [diff] [blame] | 169 | std::unique_ptr<SampleMap> snapshot = |
| 170 | std::make_unique<SampleMap>(name_hash()); |
bcwhite | c85a1f82 | 2016-02-18 21:22:14 | [diff] [blame] | 171 | base::AutoLock auto_lock(lock_); |
Luc Nguyen | 257ecb0 | 2023-04-11 21:09:41 | [diff] [blame] | 172 | snapshot->Extract(*unlogged_samples_); |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 173 | logged_samples_->Add(*snapshot); |
bcwhite | c85a1f82 | 2016-02-18 21:22:14 | [diff] [blame] | 174 | return std::move(snapshot); |
| 175 | } |
| 176 | |
bcwhite | 65e57d0 | 2016-05-13 14:39:40 | [diff] [blame] | 177 | std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotFinalDelta() const { |
| 178 | DCHECK(!final_delta_created_); |
| 179 | final_delta_created_ = true; |
| 180 | |
| 181 | std::unique_ptr<SampleMap> snapshot(new SampleMap(name_hash())); |
| 182 | base::AutoLock auto_lock(lock_); |
altimin | 498c838 | 2017-05-12 17:49:18 | [diff] [blame] | 183 | snapshot->Add(*unlogged_samples_); |
bcwhite | 65e57d0 | 2016-05-13 14:39:40 | [diff] [blame] | 184 | |
bcwhite | 65e57d0 | 2016-05-13 14:39:40 | [diff] [blame] | 185 | return std::move(snapshot); |
| 186 | } |
| 187 | |
Alexei Svitkine | 1e86b0c89 | 2024-10-02 21:02:03 | [diff] [blame] | 188 | bool SparseHistogram::AddSamples(const HistogramSamples& samples) { |
[email protected] | c50c21d | 2013-01-11 21:52:44 | [diff] [blame] | 189 | base::AutoLock auto_lock(lock_); |
Alexei Svitkine | 1e86b0c89 | 2024-10-02 21:02:03 | [diff] [blame] | 190 | return unlogged_samples_->Add(samples); |
[email protected] | c50c21d | 2013-01-11 21:52:44 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | bool SparseHistogram::AddSamplesFromPickle(PickleIterator* iter) { |
| 194 | base::AutoLock auto_lock(lock_); |
altimin | 498c838 | 2017-05-12 17:49:18 | [diff] [blame] | 195 | return unlogged_samples_->AddFromPickle(iter); |
[email protected] | c50c21d | 2013-01-11 21:52:44 | [diff] [blame] | 196 | } |
| 197 | |
Nathan Memmott | c034fa4e | 2022-07-15 23:59:43 | [diff] [blame] | 198 | base::Value::Dict SparseHistogram::ToGraphDict() const { |
Jun Kokatsu | 505af9f | 2020-05-05 11:59:47 | [diff] [blame] | 199 | std::unique_ptr<HistogramSamples> snapshot = SnapshotSamples(); |
Quang Minh Tuan Nguyen | 39b1fed | 2021-03-16 00:49:38 | [diff] [blame] | 200 | return snapshot->ToGraphDict(histogram_name(), flags()); |
Jun Kokatsu | 505af9f | 2020-05-05 11:59:47 | [diff] [blame] | 201 | } |
| 202 | |
Daniel Cheng | 0d89f922 | 2017-09-22 05:05:07 | [diff] [blame] | 203 | void SparseHistogram::SerializeInfoImpl(Pickle* pickle) const { |
| 204 | pickle->WriteString(histogram_name()); |
| 205 | pickle->WriteInt(flags()); |
[email protected] | c50c21d | 2013-01-11 21:52:44 | [diff] [blame] | 206 | } |
| 207 | |
Roger McFarlane | 8952859 | 2025-02-20 20:50:27 | [diff] [blame] | 208 | SparseHistogram::SparseHistogram(DurableStringView durable_name) |
Ramon Cano Aparicio | eb4e315 | 2025-05-09 14:26:57 | [diff] [blame] | 209 | : SparseHistogram(durable_name, HashMetricName(*durable_name)) {} |
| 210 | |
| 211 | SparseHistogram::SparseHistogram(DurableStringView durable_name, |
| 212 | uint64_t name_hash) |
Roger McFarlane | 8952859 | 2025-02-20 20:50:27 | [diff] [blame] | 213 | : HistogramBase(durable_name), |
Ramon Cano Aparicio | eb4e315 | 2025-05-09 14:26:57 | [diff] [blame] | 214 | unlogged_samples_(new SampleMap(name_hash)), |
| 215 | logged_samples_(new SampleMap(unlogged_samples_->id())) { |
| 216 | DCHECK_EQ(name_hash, HashMetricName(*durable_name)) << "Name hash mismatch"; |
| 217 | } |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 218 | |
bcwhite | b0bb919 | 2016-04-18 01:33:10 | [diff] [blame] | 219 | SparseHistogram::SparseHistogram(PersistentHistogramAllocator* allocator, |
Roger McFarlane | 8952859 | 2025-02-20 20:50:27 | [diff] [blame] | 220 | DurableStringView durable_name, |
Ramon Cano Aparicio | eb4e315 | 2025-05-09 14:26:57 | [diff] [blame] | 221 | uint64_t name_hash, |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 222 | HistogramSamples::Metadata* meta, |
| 223 | HistogramSamples::Metadata* logged_meta) |
Roger McFarlane | 8952859 | 2025-02-20 20:50:27 | [diff] [blame] | 224 | : HistogramBase(durable_name), |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 225 | // While other histogram types maintain a static vector of values with |
| 226 | // sufficient space for both "active" and "logged" samples, with each |
| 227 | // SampleVector being given the appropriate half, sparse histograms |
| 228 | // have no such initial allocation. Each sample has its own record |
| 229 | // attached to a single PersistentSampleMap by a common 64-bit identifier. |
| 230 | // Since a sparse histogram has two sample maps (active and logged), |
Ramon Cano Aparicio | b2cba0f | 2025-01-22 21:26:10 | [diff] [blame] | 231 | // there must be two sets of sample records with different IDs. The |
bcwhite | 3dd85c4f | 2016-03-17 13:21:56 | [diff] [blame] | 232 | // "active" samples use, for convenience purposes, an ID matching |
| 233 | // that of the histogram while the "logged" samples use that number |
| 234 | // plus 1. |
Ramon Cano Aparicio | eb4e315 | 2025-05-09 14:26:57 | [diff] [blame] | 235 | unlogged_samples_(new PersistentSampleMap(name_hash, allocator, meta)), |
altimin | 498c838 | 2017-05-12 17:49:18 | [diff] [blame] | 236 | logged_samples_(new PersistentSampleMap(unlogged_samples_->id() + 1, |
| 237 | allocator, |
Ramon Cano Aparicio | eb4e315 | 2025-05-09 14:26:57 | [diff] [blame] | 238 | logged_meta)) { |
| 239 | DCHECK_EQ(name_hash, HashMetricName(*durable_name)) << "Name hash mismatch"; |
| 240 | } |
[email protected] | c50c21d | 2013-01-11 21:52:44 | [diff] [blame] | 241 | |
| 242 | HistogramBase* SparseHistogram::DeserializeInfoImpl(PickleIterator* iter) { |
asvitkine | 24d3e9a | 2015-05-27 05:22:14 | [diff] [blame] | 243 | std::string histogram_name; |
[email protected] | c50c21d | 2013-01-11 21:52:44 | [diff] [blame] | 244 | int flags; |
| 245 | if (!iter->ReadString(&histogram_name) || !iter->ReadInt(&flags)) { |
| 246 | DLOG(ERROR) << "Pickle error decoding Histogram: " << histogram_name; |
Ivan Kotenkov | a16212a5 | 2017-11-08 12:37:33 | [diff] [blame] | 247 | return nullptr; |
[email protected] | c50c21d | 2013-01-11 21:52:44 | [diff] [blame] | 248 | } |
| 249 | |
[email protected] | c50c21d | 2013-01-11 21:52:44 | [diff] [blame] | 250 | flags &= ~HistogramBase::kIPCSerializationSourceFlag; |
| 251 | |
| 252 | return SparseHistogram::FactoryGet(histogram_name, flags); |
| 253 | } |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 254 | |
Nathan Memmott | c034fa4e | 2022-07-15 23:59:43 | [diff] [blame] | 255 | Value::Dict SparseHistogram::GetParameters() const { |
Weilun Shi | f07fe53 | 2020-06-11 03:21:54 | [diff] [blame] | 256 | // Unlike Histogram::GetParameters, only set the type here, and no other |
| 257 | // params. The other params do not make sense for sparse histograms. |
Nathan Memmott | c034fa4e | 2022-07-15 23:59:43 | [diff] [blame] | 258 | Value::Dict params; |
| 259 | params.Set("type", HistogramTypeToString(GetHistogramType())); |
Sylvain Defresne | 0348ecfd | 2021-06-23 08:27:34 | [diff] [blame] | 260 | return params; |
[email protected] | 24a7ec5 | 2012-10-08 10:31:50 | [diff] [blame] | 261 | } |
| 262 | |
[email protected] | 7c7a4275 | 2012-08-09 05:14:15 | [diff] [blame] | 263 | } // namespace base |