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

Side by Side Diff: base/metrics/histogram.h

Issue 9447084: Refactor Pickle Read methods to use higher performance PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile (racing with incoming CLs) Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_path.cc ('k') | base/metrics/histogram.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Histogram is an object that aggregates statistics, and can summarize them in 5 // Histogram is an object that aggregates statistics, and can summarize them in
6 // various forms, including ASCII graphical, HTML, and numerically (as a 6 // various forms, including ASCII graphical, HTML, and numerically (as a
7 // vector of numbers corresponding to each of the aggregating buckets). 7 // vector of numbers corresponding to each of the aggregating buckets).
8 8
9 // It supports calls to accumulate either time intervals (which are processed 9 // It supports calls to accumulate either time intervals (which are processed
10 // as integral number of milliseconds), or arbitrary integral units. 10 // as integral number of milliseconds), or arbitrary integral units.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include <vector> 47 #include <vector>
48 48
49 #include "base/atomicops.h" 49 #include "base/atomicops.h"
50 #include "base/base_export.h" 50 #include "base/base_export.h"
51 #include "base/compiler_specific.h" 51 #include "base/compiler_specific.h"
52 #include "base/gtest_prod_util.h" 52 #include "base/gtest_prod_util.h"
53 #include "base/logging.h" 53 #include "base/logging.h"
54 #include "base/time.h" 54 #include "base/time.h"
55 55
56 class Pickle; 56 class Pickle;
57 class PickleIterator;
57 58
58 namespace base { 59 namespace base {
59 60
60 class Lock; 61 class Lock;
61 //------------------------------------------------------------------------------ 62 //------------------------------------------------------------------------------
62 // Histograms are often put in areas where they are called many many times, and 63 // Histograms are often put in areas where they are called many many times, and
63 // performance is critical. As a result, they are designed to have a very low 64 // performance is critical. As a result, they are designed to have a very low
64 // recurring cost of executing (adding additional samples). Toward that end, 65 // recurring cost of executing (adding additional samples). Toward that end,
65 // the macros declare a static pointer to the histogram in question, and only 66 // the macros declare a static pointer to the histogram in question, and only
66 // take a "slow path" to construct (or find) the histogram on the first run 67 // take a "slow path" to construct (or find) the histogram on the first run
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 Count counts(size_t i) const { return counts_[i]; } 398 Count counts(size_t i) const { return counts_[i]; }
398 Count TotalCount() const; 399 Count TotalCount() const;
399 int64 sum() const { return sum_; } 400 int64 sum() const { return sum_; }
400 int64 redundant_count() const { return redundant_count_; } 401 int64 redundant_count() const { return redundant_count_; }
401 402
402 // Arithmetic manipulation of corresponding elements of the set. 403 // Arithmetic manipulation of corresponding elements of the set.
403 void Add(const SampleSet& other); 404 void Add(const SampleSet& other);
404 void Subtract(const SampleSet& other); 405 void Subtract(const SampleSet& other);
405 406
406 bool Serialize(Pickle* pickle) const; 407 bool Serialize(Pickle* pickle) const;
407 bool Deserialize(void** iter, const Pickle& pickle); 408 bool Deserialize(PickleIterator* iter);
408 409
409 protected: 410 protected:
410 // Actual histogram data is stored in buckets, showing the count of values 411 // Actual histogram data is stored in buckets, showing the count of values
411 // that fit into each bucket. 412 // that fit into each bucket.
412 Counts counts_; 413 Counts counts_;
413 414
414 // Save simple stats locally. Note that this MIGHT get done in base class 415 // Save simple stats locally. Note that this MIGHT get done in base class
415 // without shared memory at some point. 416 // without shared memory at some point.
416 int64 sum_; // sum of samples. 417 int64 sum_; // sum of samples.
417 418
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 // Helper method for transforming an array of valid enumeration values 751 // Helper method for transforming an array of valid enumeration values
751 // to the std::vector<int> expected by HISTOGRAM_CUSTOM_ENUMERATION. 752 // to the std::vector<int> expected by HISTOGRAM_CUSTOM_ENUMERATION.
752 // This function ensures that a guard bucket exists right after any 753 // This function ensures that a guard bucket exists right after any
753 // valid sample value (unless the next higher sample is also a valid value), 754 // valid sample value (unless the next higher sample is also a valid value),
754 // so that invalid samples never fall into the same bucket as valid samples. 755 // so that invalid samples never fall into the same bucket as valid samples.
755 static std::vector<Sample> ArrayToCustomRanges(const Sample* values, 756 static std::vector<Sample> ArrayToCustomRanges(const Sample* values,
756 size_t num_values); 757 size_t num_values);
757 758
758 // Helper for deserializing CustomHistograms. |*ranges| should already be 759 // Helper for deserializing CustomHistograms. |*ranges| should already be
759 // correctly sized before this call. Return true on success. 760 // correctly sized before this call. Return true on success.
760 static bool DeserializeRanges(void** iter, const Pickle& pickle, 761 static bool DeserializeRanges(PickleIterator* iter,
761 std::vector<Histogram::Sample>* ranges); 762 std::vector<Histogram::Sample>* ranges);
762 763
763 764
764 protected: 765 protected:
765 CustomHistogram(const std::string& name, 766 CustomHistogram(const std::string& name,
766 const std::vector<Sample>& custom_ranges); 767 const std::vector<Sample>& custom_ranges);
767 768
768 virtual bool SerializeRanges(Pickle* pickle) const OVERRIDE; 769 virtual bool SerializeRanges(Pickle* pickle) const OVERRIDE;
769 770
770 // Initialize ranges_ mapping in cached_ranges_. 771 // Initialize ranges_ mapping in cached_ranges_.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 // of our data, and to quickly see if some other CachedRanges instance is 893 // of our data, and to quickly see if some other CachedRanges instance is
893 // possibly Equal() to this instance. 894 // possibly Equal() to this instance.
894 uint32 range_checksum_; 895 uint32 range_checksum_;
895 896
896 DISALLOW_COPY_AND_ASSIGN(CachedRanges); 897 DISALLOW_COPY_AND_ASSIGN(CachedRanges);
897 }; 898 };
898 899
899 } // namespace base 900 } // namespace base
900 901
901 #endif // BASE_METRICS_HISTOGRAM_H_ 902 #endif // BASE_METRICS_HISTOGRAM_H_
OLDNEW
« no previous file with comments | « base/file_path.cc ('k') | base/metrics/histogram.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698