-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APROF-82] JMH benchmarks module with simple microbenchmarks to measu…
…re aprof performance impact
- Loading branch information
Showing
3 changed files
with
312 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.devexperts.aprof</groupId> | ||
<artifactId>aprof</artifactId> | ||
<version>27-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>benchmark</artifactId> | ||
<version>27-SNAPSHOT</version> | ||
<name>JMH benchmarks</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-core</artifactId> | ||
<version>0.3.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.0</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<finalName>microbenchmarks</finalName> | ||
<transformers> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>org.openjdk.jmh.Main</mainClass> | ||
</transformer> | ||
</transformers> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/services/javax.annotation.processing.Processor</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
49 changes: 49 additions & 0 deletions
49
benchmark/src/main/java/com/devexperts/aprof/benchmark/Benchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Aprof - Java Memory Allocation Profiler | ||
* Copyright (C) 2002-2014 Devexperts LLC | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.devexperts.aprof.benchmark; | ||
|
||
import org.openjdk.jmh.annotations.GenerateMicroBenchmark; | ||
|
||
public class Benchmark { | ||
@GenerateMicroBenchmark | ||
public Box testNew() { | ||
return newBox(); | ||
} | ||
|
||
@GenerateMicroBenchmark | ||
public int testEscapeAnalysis() { | ||
return newBox().getValue(); | ||
} | ||
|
||
private static Box newBox() { | ||
return new Box(1); | ||
} | ||
|
||
private static class Box { | ||
private int value; | ||
|
||
Box(int value) { | ||
this.value = value; | ||
} | ||
|
||
private int getValue() { | ||
return value; | ||
} | ||
} | ||
} |
Oops, something went wrong.