From c69de75cfb0f43d276f7def981ed5a74034fa7dc Mon Sep 17 00:00:00 2001 From: Roman Elizarov Date: Tue, 4 Feb 2014 08:08:00 +0000 Subject: [PATCH] [APROF-82] JMH benchmarks module with simple microbenchmarks to measure aprof performance impact --- benchmark/pom.xml | 63 +++ .../devexperts/aprof/benchmark/Benchmark.java | 49 +++ pom.xml | 400 +++++++++--------- 3 files changed, 312 insertions(+), 200 deletions(-) create mode 100644 benchmark/pom.xml create mode 100644 benchmark/src/main/java/com/devexperts/aprof/benchmark/Benchmark.java diff --git a/benchmark/pom.xml b/benchmark/pom.xml new file mode 100644 index 0000000..8c67dec --- /dev/null +++ b/benchmark/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + com.devexperts.aprof + aprof + 27-SNAPSHOT + + benchmark + 27-SNAPSHOT + JMH benchmarks + + + + org.openjdk.jmh + jmh-core + 0.3.1 + + + + + + + maven-compiler-plugin + + 1.6 + 1.6 + + + + maven-shade-plugin + 2.0 + + + package + + shade + + + microbenchmarks + + + org.openjdk.jmh.Main + + + + + *:* + + META-INF/services/javax.annotation.processing.Processor + + + + + + + + + + diff --git a/benchmark/src/main/java/com/devexperts/aprof/benchmark/Benchmark.java b/benchmark/src/main/java/com/devexperts/aprof/benchmark/Benchmark.java new file mode 100644 index 0000000..7d2c752 --- /dev/null +++ b/benchmark/src/main/java/com/devexperts/aprof/benchmark/Benchmark.java @@ -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 . + */ + +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; + } + } +} diff --git a/pom.xml b/pom.xml index 6b67111..46559dd 100644 --- a/pom.xml +++ b/pom.xml @@ -1,200 +1,200 @@ - - - - 4.0.0 - - com.devexperts.aprof - aprof - 27-SNAPSHOT - pom - - Aprof - http://code.devexperts.com/display/Aprof - - - UTF-8 - UTF-8 - - - - scm:svn:http://svn-code.devexperts.com/code/aprof/trunk - scm:svn:http://svn-code.devexperts.com/coderw/aprof/trunk - - - - transformer - core - agent - - - - - junit - junit - 3.8.1 - test - - - - - - - maven-compiler-plugin - - 1.5 - 1.5 - - - - maven-release-plugin - - true - http://svn-code.devexperts.com/coderw/aprof/tags - - - - maven-deploy-plugin - true - - true - - - - - org.apache.maven.wagon - wagon-scm - 2.2 - - - org.apache.maven.scm - maven-scm-manager-plexus - 1.8.1 - - - org.apache.maven.scm - maven-scm-api - 1.8.1 - - - org.apache.maven.scm - maven-scm-provider-svnexe - 1.8.1 - - - - - maven-source-plugin - true - - - attach-sources - none - - - - - org.codehaus.plexus - plexus-maven-plugin - true - - - maven-enforcer-plugin - - - - - 3.0.4 - - - Best Practice is to always define plugin versions! - true - true - false - - - - - - - enforce - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - - org.apache.maven.plugins - maven-dependency-plugin - 2.2 - - - org.apache.maven.plugins - maven-jar-plugin - 2.3.1 - - - org.apache.maven.plugins - maven-assembly-plugin - 2.2.1 - - - org.apache.maven.plugins - maven-release-plugin - 2.2.1 - - - org.apache.maven.plugins - maven-deploy-plugin - 2.6 - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.0.1 - - - org.codehaus.plexus - plexus-maven-plugin - 1.3.8 - - - - - - - - remote-repository - Subversion Repository - scm:svn:http://svn-code.devexperts.com/coderw/aprof/releases - - - + + + 4.0.0 + + com.devexperts.aprof + aprof + 27-SNAPSHOT + pom + + Aprof + http://code.devexperts.com/display/Aprof + + + UTF-8 + UTF-8 + + + + scm:svn:http://svn-code.devexperts.com/code/aprof/trunk + scm:svn:http://svn-code.devexperts.com/coderw/aprof/trunk + + + + transformer + core + agent + benchmark + + + + + junit + junit + 3.8.1 + test + + + + + + + maven-compiler-plugin + + 1.5 + 1.5 + + + + maven-release-plugin + + true + http://svn-code.devexperts.com/coderw/aprof/tags + + + + maven-deploy-plugin + true + + true + + + + + org.apache.maven.wagon + wagon-scm + 2.2 + + + org.apache.maven.scm + maven-scm-manager-plexus + 1.8.1 + + + org.apache.maven.scm + maven-scm-api + 1.8.1 + + + org.apache.maven.scm + maven-scm-provider-svnexe + 1.8.1 + + + + + maven-source-plugin + true + + + attach-sources + none + + + + + org.codehaus.plexus + plexus-maven-plugin + true + + + maven-enforcer-plugin + + + + + 3.0.4 + + + Best Practice is to always define plugin versions! + true + true + false + + + + + + + enforce + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + org.apache.maven.plugins + maven-dependency-plugin + 2.2 + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2.1 + + + org.apache.maven.plugins + maven-release-plugin + 2.2.1 + + + org.apache.maven.plugins + maven-deploy-plugin + 2.6 + + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.0.1 + + + org.codehaus.plexus + plexus-maven-plugin + 1.3.8 + + + + + + + + remote-repository + Subversion Repository + scm:svn:http://svn-code.devexperts.com/coderw/aprof/releases + + + \ No newline at end of file