1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include "common/histogram.h"
16 #include "common/Formatter.h"
19 void pow2_hist_t::dump(Formatter *f) const
21 f->open_array_section("histogram");
22 for (std::vector<int32_t>::const_iterator p = h.begin(); p != h.end(); ++p)
23 f->dump_int("count", *p);
25 f->dump_int("upper_bound", upper_bound());
28 void pow2_hist_t::encode(bufferlist& bl) const
30 ENCODE_START(1, 1, bl);
35 void pow2_hist_t::decode(bufferlist::iterator& p)
42 void pow2_hist_t::generate_test_instances(std::list<pow2_hist_t*>& ls)
44 ls.push_back(new pow2_hist_t);
45 ls.push_back(new pow2_hist_t);
46 ls.back()->h.push_back(1);
47 ls.back()->h.push_back(3);
48 ls.back()->h.push_back(0);
49 ls.back()->h.push_back(2);
52 void pow2_hist_t::decay(int bits)
54 for (std::vector<int32_t>::iterator p = h.begin(); p != h.end(); ++p) {