Histogram.hh (8608:02d7ac5fb855) Histogram.hh (9497:2759161b9d7f)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 23 unchanged lines hidden (view full) ---

32#include <iostream>
33#include <vector>
34
35#include "mem/ruby/common/TypeDefines.hh"
36
37class Histogram
38{
39 public:
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 23 unchanged lines hidden (view full) ---

32#include <iostream>
33#include <vector>
34
35#include "mem/ruby/common/TypeDefines.hh"
36
37class Histogram
38{
39 public:
40 Histogram(int binsize = 1, int bins = 50);
40 Histogram(int binsize = 1, uint32_t bins = 50);
41 ~Histogram();
42
43 void add(int64 value);
41 ~Histogram();
42
43 void add(int64 value);
44 void add(const Histogram& hist);
45 void clear() { clear(m_bins); }
46 void clear(int bins);
47 void clear(int binsize, int bins);
48 int64 size() const { return m_count; }
49 int getBins() const { return m_bins; }
44 void add(Histogram& hist);
45 void doubleBinSize();
46
47 void clear() { clear(m_data.size()); }
48 void clear(uint32_t bins);
49 void clear(int binsize, uint32_t bins);
50
51 uint64_t size() const { return m_count; }
52 uint32_t getBins() const { return m_data.size(); }
50 int getBinSize() const { return m_binsize; }
51 int64 getTotal() const { return m_sumSamples; }
53 int getBinSize() const { return m_binsize; }
54 int64 getTotal() const { return m_sumSamples; }
52 int64 getData(int index) const { return m_data[index]; }
55 uint64_t getSquaredTotal() const { return m_sumSquaredSamples; }
56 uint64_t getData(int index) const { return m_data[index]; }
57 int64 getMax() const { return m_max; }
53
54 void printWithMultiplier(std::ostream& out, double multiplier) const;
55 void printPercent(std::ostream& out) const;
56 void print(std::ostream& out) const;
57
58private:
58
59 void printWithMultiplier(std::ostream& out, double multiplier) const;
60 void printPercent(std::ostream& out) const;
61 void print(std::ostream& out) const;
62
63private:
59 std::vector<int64> m_data;
64 std::vector<uint64_t> m_data;
60 int64 m_max; // the maximum value seen so far
65 int64 m_max; // the maximum value seen so far
61 int64 m_count; // the number of elements added
66 uint64_t m_count; // the number of elements added
62 int m_binsize; // the size of each bucket
67 int m_binsize; // the size of each bucket
63 int m_bins; // the number of buckets
64 int m_largest_bin; // the largest bin used
68 uint32_t m_largest_bin; // the largest bin used
65
66 int64 m_sumSamples; // the sum of all samples
69
70 int64 m_sumSamples; // the sum of all samples
67 int64 m_sumSquaredSamples; // the sum of the square of all samples
71 uint64_t m_sumSquaredSamples; // the sum of the square of all samples
68
69 double getStandardDeviation() const;
70};
71
72bool node_less_then_eq(const Histogram* n1, const Histogram* n2);
73
74inline std::ostream&
75operator<<(std::ostream& out, const Histogram& obj)
76{
77 obj.print(out);
78 out << std::flush;
79 return out;
80}
81
82#endif // __MEM_RUBY_COMMON_HISTOGRAM_HH__
72
73 double getStandardDeviation() const;
74};
75
76bool node_less_then_eq(const Histogram* n1, const Histogram* n2);
77
78inline std::ostream&
79operator<<(std::ostream& out, const Histogram& obj)
80{
81 obj.print(out);
82 out << std::flush;
83 return out;
84}
85
86#endif // __MEM_RUBY_COMMON_HISTOGRAM_HH__