Skip to content

Commit

Permalink
[APROF-82] JMH benchmarks module with simple microbenchmarks to measu…
Browse files Browse the repository at this point in the history
…re aprof performance impact
  • Loading branch information
elizarov committed Feb 4, 2014
1 parent ff49140 commit c69de75
Show file tree
Hide file tree
Showing 3 changed files with 312 additions and 200 deletions.
63 changes: 63 additions & 0 deletions benchmark/pom.xml
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>
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;
}
}
}
Loading

0 comments on commit c69de75

Please sign in to comment.