Skip to content

Commit 032c94a

Browse files
committed
Instrumentation levels
1 parent 43bfb13 commit 032c94a

109 files changed

Lines changed: 7577 additions & 474 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmark/maven/pom.xml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
<!--
2+
Copyright (c) 2005, 2014, 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. Oracle designates this
8+
particular file as subject to the "Classpath" exception as provided
9+
by Oracle in the LICENSE file that accompanied this code.
10+
11+
This code is distributed in the hope that it will be useful, but WITHOUT
12+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
version 2 for more details (a copy is included in the LICENSE file that
15+
accompanied this code).
16+
17+
You should have received a copy of the GNU General Public License version
18+
2 along with this work; if not, write to the Free Software Foundation,
19+
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
21+
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
or visit www.oracle.com if you need additional information or have any
23+
questions.
24+
-->
25+
26+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
27+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<groupId>net.java.btrace</groupId>
31+
<artifactId>benchmark</artifactId>
32+
<version>1.0-SNAPSHOT</version>
33+
<packaging>jar</packaging>
34+
35+
<name>BTrace Benchmark</name>
36+
37+
<prerequisites>
38+
<maven>3.0</maven>
39+
</prerequisites>
40+
41+
<dependencies>
42+
<dependency>
43+
<groupId>org.openjdk.jmh</groupId>
44+
<artifactId>jmh-core</artifactId>
45+
<version>${jmh.version}</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.openjdk.jmh</groupId>
49+
<artifactId>jmh-generator-annprocess</artifactId>
50+
<version>${jmh.version}</version>
51+
<scope>provided</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>com.sun.tools.btrace</groupId>
55+
<artifactId>btrace-client</artifactId>
56+
<version>1.3-SNAPSHOT</version>
57+
</dependency>
58+
<dependency>
59+
<groupId>com.sun.tools.btrace</groupId>
60+
<artifactId>btrace-agent</artifactId>
61+
<version>1.3-SNAPSHOT</version>
62+
</dependency>
63+
<dependency>
64+
<groupId>com.sun.tools.btrace</groupId>
65+
<artifactId>btrace-boot</artifactId>
66+
<version>1.3-SNAPSHOT</version>
67+
</dependency>
68+
<dependency>
69+
<groupId>sun.jdk</groupId>
70+
<artifactId>tools</artifactId>
71+
</dependency>
72+
</dependencies>
73+
74+
<properties>
75+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
76+
<jmh.version>1.7.1</jmh.version>
77+
<classes.jar>${java.home}/../Classes/classes.jar</classes.jar>
78+
<tools.jar>${java.home}/../lib/tools.jar</tools.jar>
79+
</properties>
80+
81+
<build>
82+
<plugins>
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-compiler-plugin</artifactId>
86+
<version>3.1</version>
87+
<configuration>
88+
<compilerVersion>1.6</compilerVersion>
89+
<source>1.8</source>
90+
<target>1.8</target>
91+
</configuration>
92+
</plugin>
93+
<plugin>
94+
<groupId>org.apache.maven.plugins</groupId>
95+
<artifactId>maven-shade-plugin</artifactId>
96+
<version>2.2</version>
97+
<executions>
98+
<execution>
99+
<phase>package</phase>
100+
<goals>
101+
<goal>shade</goal>
102+
</goals>
103+
<configuration>
104+
<finalName>benchmarks</finalName>
105+
<transformers>
106+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
107+
<mainClass>org.openjdk.jmh.Main</mainClass>
108+
</transformer>
109+
</transformers>
110+
<artifactSet>
111+
<excludes>
112+
<exclude>com.sun.tools.btrace:*</exclude>
113+
</excludes>
114+
</artifactSet>
115+
</configuration>
116+
</execution>
117+
</executions>
118+
</plugin>
119+
<plugin>
120+
<groupId>org.codehaus.mojo</groupId>
121+
<artifactId>exec-maven-plugin</artifactId>
122+
<version>1.1.1</version>
123+
<executions>
124+
<execution>
125+
<phase>process-resources</phase>
126+
<goals>
127+
<goal>exec</goal>
128+
</goals>
129+
<configuration>
130+
<executable>${java.home}/bin/java</executable>
131+
<arguments>
132+
<argument>-cp</argument>
133+
<classpath/>
134+
<argument>com.sun.btrace.compiler.Compiler</argument>
135+
<argument>-d</argument>
136+
<argument>${basedir}/target/classes/</argument>
137+
<argument>${basedir}/src/main/resources/scripts/TraceScript.java</argument>
138+
</arguments>
139+
</configuration>
140+
</execution>
141+
</executions>
142+
</plugin>
143+
</plugins>
144+
<pluginManagement>
145+
<plugins>
146+
<plugin>
147+
<artifactId>maven-clean-plugin</artifactId>
148+
<version>2.5</version>
149+
</plugin>
150+
<plugin>
151+
<artifactId>maven-deploy-plugin</artifactId>
152+
<version>2.8.1</version>
153+
</plugin>
154+
<plugin>
155+
<artifactId>maven-install-plugin</artifactId>
156+
<version>2.5.1</version>
157+
</plugin>
158+
<plugin>
159+
<artifactId>maven-jar-plugin</artifactId>
160+
<version>2.4</version>
161+
</plugin>
162+
<plugin>
163+
<artifactId>maven-javadoc-plugin</artifactId>
164+
<version>2.9.1</version>
165+
</plugin>
166+
<plugin>
167+
<artifactId>maven-resources-plugin</artifactId>
168+
<version>2.6</version>
169+
</plugin>
170+
<plugin>
171+
<artifactId>maven-site-plugin</artifactId>
172+
<version>3.3</version>
173+
</plugin>
174+
<plugin>
175+
<artifactId>maven-source-plugin</artifactId>
176+
<version>2.2.1</version>
177+
</plugin>
178+
<plugin>
179+
<artifactId>maven-surefire-plugin</artifactId>
180+
<version>2.17</version>
181+
</plugin>
182+
</plugins>
183+
</pluginManagement>
184+
</build>
185+
<profiles>
186+
<profile>
187+
<id>mac</id>
188+
<activation>
189+
<file>
190+
<exists>${classes.jar}</exists>
191+
</file>
192+
</activation>
193+
<dependencyManagement>
194+
<dependencies>
195+
<dependency>
196+
<groupId>sun.jdk</groupId>
197+
<artifactId>tools</artifactId>
198+
<version>1.6.0</version>
199+
<scope>system</scope>
200+
<systemPath>${classes.jar}</systemPath>
201+
</dependency>
202+
</dependencies>
203+
</dependencyManagement>
204+
</profile>
205+
<profile>
206+
<activation>
207+
<activeByDefault>true</activeByDefault>
208+
</activation>
209+
<dependencyManagement>
210+
<dependencies>
211+
<dependency>
212+
<groupId>sun.jdk</groupId>
213+
<artifactId>tools</artifactId>
214+
<version>1.7.0</version>
215+
<scope>system</scope>
216+
<systemPath>${tools.jar}</systemPath>
217+
</dependency>
218+
</dependencies>
219+
</dependencyManagement>
220+
</profile>
221+
</profiles>
222+
<description>A JMH benchmar to assert the overhead imposed by various types of BTrace instrumentation</description>
223+
</project>

benchmark/nb-configuration.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

benchmark/nbactions.xml

Lines changed: 0 additions & 46 deletions
This file was deleted.

benchmark/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ questions.
5353
<dependency>
5454
<groupId>com.sun.tools.btrace</groupId>
5555
<artifactId>btrace-client</artifactId>
56-
<version>1.3-SNAPSHOT</version>
56+
<version>1.3.3</version>
5757
</dependency>
5858
<dependency>
5959
<groupId>com.sun.tools.btrace</groupId>
6060
<artifactId>btrace-agent</artifactId>
61-
<version>1.3-SNAPSHOT</version>
61+
<version>1.3.3</version>
6262
</dependency>
6363
<dependency>
6464
<groupId>com.sun.tools.btrace</groupId>
6565
<artifactId>btrace-boot</artifactId>
66-
<version>1.3-SNAPSHOT</version>
66+
<version>1.3.3</version>
6767
</dependency>
6868
<dependency>
6969
<groupId>sun.jdk</groupId>
@@ -73,7 +73,7 @@ questions.
7373

7474
<properties>
7575
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
76-
<jmh.version>0.9.2</jmh.version>
76+
<jmh.version>1.7.1</jmh.version>
7777
<classes.jar>${java.home}/../Classes/classes.jar</classes.jar>
7878
<tools.jar>${java.home}/../lib/tools.jar</tools.jar>
7979
</properties>

benchmark/src/main/java/net/java/btrace/BTraceBench.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ public void testInstrumentedMethod() {
156156
counter++;
157157
}
158158

159+
@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
160+
@Measurement(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
161+
@Benchmark
162+
public void testInstrumentedMethodLevelNoMatch() {
163+
counter++;
164+
}
165+
159166
@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
160167
@Measurement(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
161168
@Benchmark
@@ -280,10 +287,10 @@ public static void main(String[] args) throws Exception {
280287
BTraceConfig bc = getConfig();
281288
try {
282289
Options opt = new OptionsBuilder()
283-
.addProfiler(ProfilerFactory.getProfilerByName("gc"))
290+
.addProfiler(ProfilerFactory.getProfilerByName("stack"))
284291
.jvmArgsPrepend("-javaagent:" + bc.agentJar + "=noServer=true,"
285292
+ "script=" + bc.scriptPath)
286-
.include(".*" + BTraceBench.class.getSimpleName() + ".*test.*")
293+
.include(".*" + BTraceBench.class.getSimpleName() + ".*test")
287294
.build();
288295

289296
new Runner(opt).run();

benchmark/src/main/resources/scripts/TraceScript.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.sun.btrace.annotations.BTrace;
55
import com.sun.btrace.annotations.Duration;
66
import com.sun.btrace.annotations.Kind;
7+
import com.sun.btrace.annotations.Level;
78
import com.sun.btrace.annotations.Location;
89
import com.sun.btrace.annotations.OnMethod;
910
import com.sun.btrace.annotations.ProbeClassName;
@@ -20,6 +21,11 @@ public static void onMethodEntryEmpty(@ProbeClassName String pcn, @ProbeMethodNa
2021

2122
}
2223

24+
@OnMethod(clazz="net.java.btrace.BTraceBench", method="testInstrumentedMethodLevelNoMatch", enableAt = @Level("100"))
25+
public static void onMethodEntryEmptyLevelNoMatch(@ProbeClassName String pcn, @ProbeMethodName String pmn) {
26+
27+
}
28+
2329
@OnMethod(clazz="net.java.btrace.BTraceBench", method="testInstrumentedMethodSampled")
2430
@Sampled(kind = Sampled.Sampler.Const)
2531
public static void onMethodEntryEmptySampled(@ProbeClassName String pcn, @ProbeMethodName String pmn) {

0 commit comments

Comments
 (0)