1 /*
   2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_UTILITIES_STATISTICS_HPP
  26 #define SHARE_UTILITIES_STATISTICS_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "utilities/debug.hpp"
  30 #include "utilities/globalDefinitions.hpp"
  31 #include "utilities/numberSeq.hpp"
  32 
  33 class TableRateStatistics : CHeapObj<mtStatistics> {
  34 
  35 private:
  36   volatile size_t _added_items;
  37   volatile size_t _removed_items;
  38 
  39   jlong _time_stamp;
  40   double _seconds_stamp;
  41   size_t _added_items_stamp;
  42   size_t _added_items_stamp_prev;
  43   size_t _removed_items_stamp;
  44   size_t _removed_items_stamp_prev;
  45 
  46 public:
  47   TableRateStatistics();
  48   ~TableRateStatistics();
  49 
  50   void add();
  51   void remove();
  52   void stamp();
  53   float get_add_rate();
  54   float get_remove_rate();
  55 };
  56 
  57 class TableStatistics : CHeapObj<mtStatistics> {
  58 
  59 public:
  60   bool _owned;
  61 
  62   size_t _number_of_buckets;
  63   size_t _number_of_entries;
  64 
  65   size_t _bucket_bytes;
  66   size_t _entry_bytes;
  67   size_t _bucket_size;
  68   size_t _entry_size;
  69   size_t _literal_bytes;
  70   size_t _total_footprint;
  71 
  72   size_t _maximum_bucket_size;
  73   float _average_bucket_size;
  74   float _variance_of_bucket_size;
  75   float _stddev_of_bucket_size;
  76 
  77   float _add_rate;
  78   float _remove_rate;
  79 
  80   TableStatistics();
  81   TableStatistics(TableRateStatistics& rate_stats, NumberSeq summary, size_t literal_bytes, size_t bucket_bytes, size_t node_bytes);
  82   ~TableStatistics();
  83 
  84   void print(outputStream* st, const char *table_name);
  85 };
  86 
  87 #endif // SHARE_UTILITIES_STATISTICS_HPP