1 /* 2 * Copyright (c) 2015, 2016, 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 package org.graalvm.compiler.debug; 24 25 import jdk.vm.ci.meta.ResolvedJavaMethod; 26 27 /** 28 * A set of debug metrics for all compilations of a {@link ResolvedJavaMethod}. A method metrics 29 * object is a container for several metrics per compilation of a method {@code <Method,List 30 * <CompilationData>>}. Metrics are stored on a per-method per-compilation basis. 31 * 32 * <pre> 33 * DebugMethodMetrics m = Debug.methodMetrics(method); 34 * m.incrementMetric("MyPerCompilationmetric"); 35 * </pre> 36 * 37 * In contrast to global metrics like {@link DebugCounter}, {@link DebugTimer} or 38 * {@linkplain DebugMemUseTracker}, method compilation metrics are always associated with a 39 * {@link ResolvedJavaMethod}. 40 */ 41 public interface DebugMethodMetrics { 42 43 /** 44 * Adds {@code value} to the metric for the current compilation associated with 45 * {@code metricName}. If the metric is yet undefined for the current compilation a new metric 46 * for the given name is defined and the value for it is set to {@code value}. 47 * 48 * @param metricName the name for the metric to be incremented 49 * @param value the value to add to the metric defined by name 50 */ 51 void addToMetric(long value, String metricName); 52 53 /** 54 * @see #addToMetric(long, String) 55 */ 56 void addToMetric(long value, String format, Object arg1); 57 58 /** 59 * @see #addToMetric(long, String) 60 */ 61 void addToMetric(long value, String format, Object arg1, Object arg2); 62 63 /** 64 * @see #addToMetric(long, String) 65 */ 66 void addToMetric(long value, String format, Object arg1, Object arg2, Object arg3); 67 68 /** 69 * Adds {@code 1} to the metric for the current compilation associated with {@code metricName}. 70 * If the metric is yet undefined for the current compilation a new metric for the given name is 71 * defined and the value for it is set to {@code value}. 72 * 73 * @param metricName the name for the metric to be incremented 74 */ 75 void incrementMetric(String metricName); 76 77 /** 78 * @see #incrementMetric(String) 79 */ 80 void incrementMetric(String format, Object arg1); 81 82 /** 83 * @see #incrementMetric(String) 84 */ 85 void incrementMetric(String format, Object arg1, Object arg2); 86 87 /** 88 * @see #incrementMetric(String) 89 */ 90 void incrementMetric(String format, Object arg1, Object arg2, Object arg3); 91 92 /** 93 * Gets the value of the metric for the current compilation associated with the 94 * {@code metricName} . If the metric is yet undefined for the current compilation {@code 0} is 95 * returned instead. 96 * 97 * @param metricName the name of the metric for which the value will be returned 98 * @return the value of the metric for the given compilation or {@code 0} if it is not defined 99 */ 100 long getCurrentMetricValue(String metricName); 101 102 /** 103 * @see #getCurrentMetricValue(String) 104 */ 105 long getCurrentMetricValue(String format, Object arg1); 106 107 /** 108 * @see #getCurrentMetricValue(String) 109 */ 110 long getCurrentMetricValue(String format, Object arg1, Object arg2); 111 112 /** 113 * @see #getCurrentMetricValue(String) 114 */ 115 long getCurrentMetricValue(String format, Object arg1, Object arg2, Object arg3); 116 117 /** 118 * Gets the {@link ResolvedJavaMethod} associated with this {@linkplain DebugMethodMetrics}. 119 * 120 * @return the {@link ResolvedJavaMethod} of the current method metric 121 */ 122 ResolvedJavaMethod getMethod(); 123 124 }