Last active
February 16, 2020 20:35
Revisions
-
alblue revised this gist
Feb 16, 2020 . 3 changed files with 1 addition and 232 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ This project has moved to https://github.com/alblue/com.bandlem.jmh.microopts This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,115 +0,0 @@ This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,117 +0,0 @@ -
alblue revised this gist
Jun 16, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // Move this file to src/main/java in order to run with Maven // package org.sample; import org.openjdk.jmh.annotations.Benchmark; -
alblue revised this gist
Apr 26, 2016 . 1 changed file with 9 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ package org.sample; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; //import org.openjdk.jmh.annotations.CompilerControl; //import org.openjdk.jmh.annotations.CompilerControl.Mode; import org.openjdk.jmh.annotations.Scope; @@ -13,7 +14,8 @@ public class StringBenchmark { private String to = "Readers"; private String subject = "Benchmarking with JMH"; @Param({"16"}) private int size; @Benchmark public String testEmptyBuffer() { @@ -50,7 +52,7 @@ public String testHelloWorldBuffer() { @Benchmark public String testEmailBuilderSimple() { StringBuilder builder = new StringBuilder(size); builder.append("From"); builder.append(from); builder.append("To"); @@ -63,20 +65,19 @@ public String testEmailBuilderSimple() { @Benchmark public String testEmailBufferSimple() { StringBuffer buffer = new StringBuffer(size); buffer.append("From"); buffer.append(from); buffer.append("To"); buffer.append(to); buffer.append("Subject"); buffer.append(subject); return buffer.toString(); } @Benchmark public String testEmailBuilderConcat() { StringBuilder builder = new StringBuilder(size); builder.append("From" + from); builder.append("To" + to); builder.append("Subject" + subject); @@ -85,7 +86,7 @@ public String testEmailBuilderConcat() { @Benchmark public String testEmailBufferConcat() { StringBuffer buffer = new StringBuffer(size); buffer.append("From" + from); buffer.append("To" + to); buffer.append("Subject" + subject); @@ -94,13 +95,13 @@ public String testEmailBufferConcat() { @Benchmark public String testEmailBuilderChain() { return new StringBuilder(size).append("From").append(from).append("To").append(to).append("Subject") .append(subject).toString(); } @Benchmark public String testEmailBufferChain() { return new StringBuffer(size).append("From").append(from).append("To").append(to).append("Subject") .append(subject).toString(); } -
alblue revised this gist
Apr 26, 2016 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,8 @@ public class StringBenchmark { private String to = "Readers"; private String subject = "Benchmarking with JMH"; private static final int SIZE = Integer.getInteger("size", 16); @Benchmark public String testEmptyBuffer() { StringBuffer buffer = new StringBuffer(); @@ -48,7 +50,7 @@ public String testHelloWorldBuffer() { @Benchmark public String testEmailBuilderSimple() { StringBuilder builder = new StringBuilder(SIZE); builder.append("From"); builder.append(from); builder.append("To"); @@ -61,7 +63,7 @@ public String testEmailBuilderSimple() { @Benchmark public String testEmailBufferSimple() { StringBuffer buffer = new StringBuffer(SIZE); buffer.append("From"); buffer.append(from); buffer.append("To"); @@ -74,7 +76,7 @@ public String testEmailBufferSimple() { @Benchmark public String testEmailBuilderConcat() { StringBuilder builder = new StringBuilder(SIZE); builder.append("From" + from); builder.append("To" + to); builder.append("Subject" + subject); @@ -83,7 +85,7 @@ public String testEmailBuilderConcat() { @Benchmark public String testEmailBufferConcat() { StringBuffer buffer = new StringBuffer(SIZE); buffer.append("From" + from); buffer.append("To" + to); buffer.append("Subject" + subject); @@ -92,13 +94,13 @@ public String testEmailBufferConcat() { @Benchmark public String testEmailBuilderChain() { return new StringBuilder(SIZE).append("From").append(from).append("To").append(to).append("Subject") .append(subject).toString(); } @Benchmark public String testEmailBufferChain() { return new StringBuffer(SIZE).append("From").append(from).append("To").append(to).append("Subject") .append(subject).toString(); } -
alblue created this gist
Apr 26, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,110 @@ package org.sample; import org.openjdk.jmh.annotations.Benchmark; //import org.openjdk.jmh.annotations.CompilerControl; //import org.openjdk.jmh.annotations.CompilerControl.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; @State(Scope.Benchmark) //@CompilerControl(Mode.EXCLUDE) public class StringBenchmark { private String from = "Alex"; private String to = "Readers"; private String subject = "Benchmarking with JMH"; @Benchmark public String testEmptyBuffer() { StringBuffer buffer = new StringBuffer(); return buffer.toString(); } @Benchmark public String testEmptyBuilder() { StringBuilder builder = new StringBuilder(); return builder.toString(); } @Benchmark public String testEmptyLiteral() { return ""; } @Benchmark public String testHelloWorldBuilder() { StringBuilder builder = new StringBuilder(); builder.append("Hello"); builder.append("World"); return builder.toString(); } @Benchmark public String testHelloWorldBuffer() { StringBuffer buffer = new StringBuffer(); buffer.append("Hello"); buffer.append("World"); return buffer.toString(); } @Benchmark public String testEmailBuilderSimple() { StringBuilder builder = new StringBuilder(48); builder.append("From"); builder.append(from); builder.append("To"); builder.append(to); builder.append("Subject"); builder.append(subject); return builder.toString(); } @Benchmark public String testEmailBufferSimple() { StringBuffer buffer = new StringBuffer(48); buffer.append("From"); buffer.append(from); buffer.append("To"); buffer.append(to); buffer.append("Subject"); buffer.append(subject); return buffer.toString(); } @Benchmark public String testEmailBuilderConcat() { StringBuilder builder = new StringBuilder(48); builder.append("From" + from); builder.append("To" + to); builder.append("Subject" + subject); return builder.toString(); } @Benchmark public String testEmailBufferConcat() { StringBuffer buffer = new StringBuffer(48); buffer.append("From" + from); buffer.append("To" + to); buffer.append("Subject" + subject); return buffer.toString(); } @Benchmark public String testEmailBuilderChain() { return new StringBuilder(48).append("From").append(from).append("To").append(to).append("Subject") .append(subject).toString(); } @Benchmark public String testEmailBufferChain() { return new StringBuffer(48).append("From").append(from).append("To").append(to).append("Subject") .append(subject).toString(); } @Benchmark public String testEmailLiteral() { return "From" + from + "To" + to + "Subject" + subject; } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,117 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>string-benchmark</artifactId> <version>1.0</version> <packaging>jar</packaging> <name>StringBenchmark</name> <prerequisites> <maven>3.0</maven> </prerequisites> <dependencies> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-core</artifactId> <version>${jmh.version}</version> </dependency> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-generator-annprocess</artifactId> <version>${jmh.version}</version> <scope>provided</scope> </dependency> </dependencies> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <jmh.version>1.12</jmh.version> <javac.target>1.6</javac.target> <uberjar.name>benchmarks</uberjar.name> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <compilerVersion>${javac.target}</compilerVersion> <source>${javac.target}</source> <target>${javac.target}</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.2</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <finalName>${uberjar.name}</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/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin> </plugins> <pluginManagement> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>2.5</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.1</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.1</version> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> </plugin> <plugin> <artifactId>maven-javadoc-plugin</artifactId> <version>2.9.1</version> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> </plugin> <plugin> <artifactId>maven-site-plugin</artifactId> <version>3.3</version> </plugin> <plugin> <artifactId>maven-source-plugin</artifactId> <version>2.2.1</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.17</version> </plugin> </plugins> </pluginManagement> </build> </project>