Tue, 23 Nov 2010 13:22:55 -0800
6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg
ysr@777 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
ysr@777 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ysr@777 | 4 | * |
ysr@777 | 5 | * This code is free software; you can redistribute it and/or modify it |
ysr@777 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ysr@777 | 7 | * published by the Free Software Foundation. |
ysr@777 | 8 | * |
ysr@777 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ysr@777 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ysr@777 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ysr@777 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
ysr@777 | 13 | * accompanied this code). |
ysr@777 | 14 | * |
ysr@777 | 15 | * You should have received a copy of the GNU General Public License version |
ysr@777 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
ysr@777 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ysr@777 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
ysr@777 | 22 | * |
ysr@777 | 23 | */ |
ysr@777 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_UTILITIES_INTHISTO_HPP |
stefank@2314 | 26 | #define SHARE_VM_UTILITIES_INTHISTO_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "memory/allocation.hpp" |
stefank@2314 | 29 | #include "utilities/growableArray.hpp" |
stefank@2314 | 30 | |
ysr@777 | 31 | // This class implements a simple histogram. |
ysr@777 | 32 | |
ysr@777 | 33 | // A histogram summarizes a series of "measurements", each of which is |
ysr@777 | 34 | // assumed (required in this implementation) to have an outcome that is a |
ysr@777 | 35 | // non-negative integer. The histogram efficiently maps measurement outcomes |
ysr@777 | 36 | // to the number of measurements had that outcome. |
ysr@777 | 37 | |
ysr@777 | 38 | // To print the results, invoke print() on your Histogram*. |
ysr@777 | 39 | |
ysr@777 | 40 | // Note: there is already an existing "Histogram" class, in file |
ysr@777 | 41 | // histogram.{hpp,cpp}, but to my mind that's not a histogram, it's a table |
ysr@777 | 42 | // mapping strings to counts. To be a histogram (IMHO) it needs to map |
ysr@777 | 43 | // numbers (in fact, integers) to number of occurrences of that number. |
ysr@777 | 44 | |
ysr@777 | 45 | // ysr: (i am not sure i agree with the above note.) i suspect we want to have a |
ysr@777 | 46 | // histogram template that will map an arbitrary type (with a defined order |
ysr@777 | 47 | // relation) to a count. |
ysr@777 | 48 | |
ysr@777 | 49 | |
ysr@777 | 50 | class IntHistogram : public CHeapObj { |
ysr@777 | 51 | protected: |
ysr@777 | 52 | int _max; |
ysr@777 | 53 | int _tot; |
ysr@777 | 54 | GrowableArray<int>* _elements; |
ysr@777 | 55 | |
ysr@777 | 56 | public: |
ysr@777 | 57 | // Create a new, empty table. "est" is an estimate of the maximum outcome |
ysr@777 | 58 | // that will be added, and "max" is an outcome such that all outcomes at |
ysr@777 | 59 | // least that large will be bundled with it. |
ysr@777 | 60 | IntHistogram(int est, int max); |
ysr@777 | 61 | // Add a measurement with the given outcome to the sequence. |
ysr@777 | 62 | void add_entry(int outcome); |
ysr@777 | 63 | // Return the number of entries recorded so far with the given outcome. |
ysr@777 | 64 | int entries_for_outcome(int outcome); |
ysr@777 | 65 | // Return the total number of entries recorded so far. |
ysr@777 | 66 | int total_entries() { return _tot; } |
ysr@777 | 67 | // Return the number of entries recorded so far with the given outcome as |
ysr@777 | 68 | // a fraction of the total number recorded so far. |
ysr@777 | 69 | double fraction_for_outcome(int outcome) { |
ysr@777 | 70 | return |
ysr@777 | 71 | (double)entries_for_outcome(outcome)/ |
ysr@777 | 72 | (double)total_entries(); |
ysr@777 | 73 | } |
ysr@777 | 74 | // Print the histogram on the given output stream. |
ysr@777 | 75 | void print_on(outputStream* st) const; |
ysr@777 | 76 | }; |
stefank@2314 | 77 | |
stefank@2314 | 78 | #endif // SHARE_VM_UTILITIES_INTHISTO_HPP |