001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Eclipse Public License (EPL);
005 * You may not use this file except in compliance with the License. You
006 * may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.jikesrvm.adaptive.database.methodsamples;
014
015 import org.jikesrvm.VM;
016 import org.jikesrvm.compilers.common.CompiledMethod;
017
018 /**
019 * Wrapper around a pair of parallel arrays:
020 * (1) an array of compiled method id's
021 * (2) an array of counts: how many times each compiled method id is counted
022 */
023 public final class MethodCountSet {
024 /**
025 * array of compiled methods
026 */
027 CompiledMethod[] cms;
028 /**
029 * array of counts
030 */
031 double[] counters;
032
033 /**
034 * Constructor
035 *
036 * @param _cms array of compiled method ids
037 * @param _counters array of counters
038 */
039 MethodCountSet(CompiledMethod[] _cms, double[] _counters) {
040 if (VM.VerifyAssertions) VM._assert(_cms.length == _counters.length);
041 cms = _cms;
042 counters = _counters;
043 }
044
045 /**
046 * String representation of fields
047 *
048 * @return string representation of compiled method id's and thier counts
049 */
050 public String toString() {
051 String ans = "";
052 for (int i = 0; i < cms.length; i++) {
053 ans += cms[i] + " = " + counters[i] + "\n";
054 }
055 return ans;
056 }
057 }