annotate test/compiler/testlibrary/rtm/RTMLockingStatistics.java @ 18408:2c3666f44855

Truffle: initial commit of object API implementation
author Andreas Woess <andreas.woess@jku.at>
date Tue, 18 Nov 2014 23:19:43 +0100
parents 665bbe93823f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17871
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
1 /*
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
4 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
7 * published by the Free Software Foundation.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
8 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
13 * accompanied this code).
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
14 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
18 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
21 * questions.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
22 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
23 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
24
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
25 package rtm;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
26
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
27 import java.util.EnumMap;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
28 import java.util.LinkedList;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
29 import java.util.List;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
30 import java.util.Map;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
31 import java.util.regex.Pattern;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
32 import java.util.regex.Matcher;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
33
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
34 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
35 * Wrapper for +UsePreciseRTMLockingStatistics output.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
36 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
37 * Example of locking statistics:
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
38 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
39 * java/lang/ClassLoader.loadClass@7
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
40 * # rtm locks total (estimated): 0
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
41 * # rtm lock aborts : 13
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
42 * # rtm lock aborts 0: 12
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
43 * # rtm lock aborts 1: 0
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
44 * # rtm lock aborts 2: 0
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
45 * # rtm lock aborts 3: 0
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
46 * # rtm lock aborts 4: 0
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
47 * # rtm lock aborts 5: 0
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
48 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
49 public class RTMLockingStatistics {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
50 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
51 * Pattern for aborts per abort type entries.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
52 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
53 private static final Pattern ABORT_PATTERN;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
54
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
55 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
56 * Pattern for whole statistics.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
57 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
58 private static final Pattern RTM_LOCKING_STATISTICS_PATTERN;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
59
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
60 static {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
61 String abortRe
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
62 = "# rtm lock aborts\\s+(?<type>[0-9]+):\\s(?<count>[0-9]+)";
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
63
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
64 ABORT_PATTERN = Pattern.compile(abortRe);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
65 RTM_LOCKING_STATISTICS_PATTERN = Pattern.compile(
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
66 "(?<className>[^.\n]+)\\." +
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
67 "(?<methodName>[^@\n]+)@(?<bci>[0-9]+)\n" +
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
68 "# rtm locks total \\(estimated\\):\\s*" +
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
69 "(?<totalLocks>[0-9]+)\n" +
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
70 "# rtm lock aborts\\s+:\\s*(?<totalAborts>[0-9]+)\n" +
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
71 "(?<abortStats>(" + abortRe + "\n)+)");
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
72 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
73
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
74 private final long totalLocks;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
75 private final long totalAborts;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
76 private final String className;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
77 private final String methodName;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
78 private final int bci;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
79 private final Map<AbortType, Long> aborts = new EnumMap<>(AbortType.class);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
80
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
81 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
82 * Constructs RTMLockingStatistics from matcher captured statistics entry.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
83 * @param matcher Matcher captured statistics entry.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
84 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
85 private RTMLockingStatistics(Matcher matcher) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
86 className = matcher.group("className");
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
87 methodName = matcher.group("methodName");
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
88 bci = Integer.valueOf(matcher.group("bci"));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
89 totalLocks = Long.valueOf(matcher.group("totalLocks"));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
90 totalAborts = Long.valueOf(matcher.group("totalAborts"));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
91
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
92 Matcher abortMatcher = ABORT_PATTERN.matcher(matcher.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
93 group("abortStats"));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
94
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
95 while (abortMatcher.find()) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
96 int type = Integer.valueOf(abortMatcher.group("type"));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
97 long count = Long.valueOf(abortMatcher.group("count"));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
98 setAborts(AbortType.lookup(type), count);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
99 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
100 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
101
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
102
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
103 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
104 * Parses string and return all founded RTM locking statistics entries.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
105 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
106 * @param str the string to be parsed.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
107 * @return list with all founded RTM locking statistics entries or
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
108 * empty list if nothing was found.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
109 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
110 public static List<RTMLockingStatistics> fromString(String str) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
111 List<RTMLockingStatistics> statistics = new LinkedList<>();
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
112 Matcher matcher = RTM_LOCKING_STATISTICS_PATTERN.matcher(str);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
113
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
114 while (matcher.find()) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
115 RTMLockingStatistics lock = new RTMLockingStatistics(matcher);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
116 statistics.add(lock);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
117 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
118
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
119 return statistics;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
120 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
121
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
122 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
123 * Parses string and return all founded RTM locking statistics entries
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
124 * for locks in method {@code methodName}.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
125 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
126 * @param methodName a name of the method for locks from which statistics
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
127 * should be gathered.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
128 * @param str the string to be parsed.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
129 * @return list with all founded RTM locking statistics entries or
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
130 * empty list if nothing was found.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
131 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
132 public static List<RTMLockingStatistics> fromString(String methodName,
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
133 String str) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
134 String formattedMethodName = formatMethodName(methodName);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
135
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
136 List<RTMLockingStatistics> statisticsForMethod = new LinkedList<>();
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
137 for (RTMLockingStatistics statistics : fromString(str)) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
138 if (statistics.getLockName().startsWith(formattedMethodName)) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
139 statisticsForMethod.add(statistics);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
140 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
141 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
142 return statisticsForMethod;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
143 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
144
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
145 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
146 * Formats method's name so it will have the same format as
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
147 * in rtm locking statistics.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
148 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
149 * <pre>
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
150 * Example:
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
151 * com/example/Klass::method =&gt; com/example/Klass.method
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
152 * com/example/Klass.method =&gt; com/example/Klass.method
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
153 * com.example.Klass::method =&gt; com/example/Klass.method
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
154 * com.example.Klass.method =&gt; com/example/Klass.method
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
155 * </pre>
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
156 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
157 * @param methodName method's name that should be formatted.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
158 * @return formatted method's name.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
159 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
160 private static String formatMethodName(String methodName) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
161 String m[];
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
162 if (methodName.contains("::")) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
163 m = methodName.split("::");
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
164 } else {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
165 int splitAt = methodName.lastIndexOf('.');
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
166 m = new String[2];
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
167 m[0] = methodName.substring(0, splitAt);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
168 m[1] = methodName.substring(splitAt + 1);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
169 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
170 return String.format("%s.%s", m[0].replaceAll("\\.", "/"), m[1]);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
171 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
172
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
173 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
174 * Returns name of lock for which this statistics was collected.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
175 * Lock name has following format:
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
176 * &lt;class name&gt;.&lt;method name&gt;@&lt;bci&gt;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
177 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
178 * @return name of lock.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
179 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
180 public String getLockName() {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
181 return String.format("%s.%s@%d", className, methodName, bci);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
182 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
183
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
184 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
185 * Returns aborts count for specified abort type.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
186 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
187 * @param type an abort type.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
188 * @return count of aborts.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
189 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
190 public long getAborts(AbortType type) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
191 return aborts.getOrDefault(type, 0L);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
192 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
193
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
194 /**
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
195 * Sets aborts count for specified abort type.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
196 *
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
197 * @param type an abort type.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
198 * @param count count of aborts.
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
199 */
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
200 public void setAborts(AbortType type, long count) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
201 aborts.put(type, count);
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
202 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
203
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
204 public long getTotalLocks() {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
205 return totalLocks;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
206 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
207
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
208 public long getTotalAborts() {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
209 return totalAborts;
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
210 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
211
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
212 @Override
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
213 public String toString() {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
214 StringBuilder builder = new StringBuilder();
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
215 builder.append(getLockName()).append('\n');
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
216 builder.append(String.format("# rtm locks total (estimated): %d\n",
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
217 getTotalLocks()));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
218 builder.append(String.format("# rtm lock aborts: %d\n",
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
219 getTotalLocks()));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
220
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
221 for (AbortType type : AbortType.values()) {
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
222 builder.append(String.format("# rtm lock aborts %s %d\n",
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
223 type.toString(), getAborts(type)));
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
224 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
225 return builder.toString();
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
226 }
665bbe93823f 8039499: Add all common classes used by tests on RTM support to testlibrary
iignatyev
parents:
diff changeset
227 }