-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First step towards JMH benchmarks as discussed in #4752
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
1 parent
1695f1f
commit 72029ed
Showing
4 changed files
with
310 additions
and
158 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,55 @@ | ||
version = ENV['JRUBY_VERSION'] || | ||
File.read(File.join(basedir, '..', 'VERSION')).strip | ||
|
||
project 'JRuby Benchmark' do | ||
|
||
model_version '4.0.0' | ||
inherit 'org.jruby:jruby-parent', version | ||
id 'org.jruby:jruby-benchmark' | ||
|
||
properties('polyglot.dump.pom' => 'pom.xml', | ||
'polyglot.dump.readonly' => true, | ||
'maven.build.timestamp.format' => 'yyyy-MM-dd', | ||
'maven.test.skip' => 'true', | ||
'build.date' => '${maven.build.timestamp}', | ||
'main.basedir' => '${project.parent.basedir}', | ||
'jruby.basedir' => '${basedir}/..', | ||
'jmh.version' => '1.19' | ||
) | ||
|
||
IO.foreach(File.join(basedir, '..', 'default.build.properties')) do |line| | ||
line.chomp! | ||
# skip comments | ||
next if line =~ /(^\W*#|^$)/ | ||
# build const name | ||
name, value = line.split('=', 2) | ||
properties name => value | ||
end | ||
|
||
jar 'org.jruby:jruby-core:${project.version}' | ||
jar 'org.openjdk.jmh:jmh-core:${jmh.version}' | ||
jar 'org.openjdk.jmh:jmh-generator-annprocess:${jmh.version}' | ||
jar 'org.openjdk.jmh:jmh-core-benchmarks:${jmh.version}' | ||
|
||
plugin(:compiler, | ||
'encoding' => 'utf-8', | ||
'debug' => 'true', | ||
'verbose' => 'true', | ||
'fork' => 'true', | ||
'compilerArgs' => { 'arg' => '-J-Xmx1G' }, | ||
'showWarnings' => 'true', | ||
'showDeprecation' => 'true', | ||
'source' => ['${base.java.version}', '1.7'], | ||
'target' => ['${base.javac.version}', '1.7'], | ||
'useIncrementalCompilation' => 'false') | ||
|
||
plugin :shade do | ||
execute_goals('shade', | ||
:id => 'create jruby-benchmark.jar', | ||
:phase => 'package', | ||
'outputFile' => '${project.build.directory}/jruby-benchmark.jar', | ||
'transformers' => [{ '@implementation' => 'org.apache.maven.plugins.shade.resource.ManifestResourceTransformer', | ||
'mainClass' => 'org.openjdk.jmh.Main' }] | ||
) | ||
end | ||
end |
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,128 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
DO NOT MODIFIY - GENERATED CODE | ||
--> | ||
<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>org.jruby</groupId> | ||
<artifactId>jruby-parent</artifactId> | ||
<version>9.2.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>jruby-benchmark</artifactId> | ||
<name>JRuby Benchmark</name> | ||
<properties> | ||
<version.ruby>2.4.1</version.ruby> | ||
<prawn.dir>${test.dir}/prawn</prawn.dir> | ||
<spec.tags.dir>${spec.dir}/tags</spec.tags.dir> | ||
<polyglot.dump.pom>pom.xml</polyglot.dump.pom> | ||
<pkg.dir>${build.dir}/pkg</pkg.dir> | ||
<spec.dir>spec</spec.dir> | ||
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format> | ||
<installer.gems>${jruby.win32ole.gem}</installer.gems> | ||
<prawn.git.repo>git://github.com/sandal/prawn.git</prawn.git.repo> | ||
<version.ruby.minor>1</version.ruby.minor> | ||
<install4j.executable>/Applications/install4j 4/bin/install4jc</install4j.executable> | ||
<jay.bin>jay</jay.bin> | ||
<polyglot.dump.readonly>true</polyglot.dump.readonly> | ||
<dest.lib.dir>${lib.dir}</dest.lib.dir> | ||
<rails.git.repo>git://github.com/rails/rails.git</rails.git.repo> | ||
<build.dir>target</build.dir> | ||
<maven.test.skip>true</maven.test.skip> | ||
<rubyspec.1.8.dir>${rubyspec.dir}/1.8</rubyspec.1.8.dir> | ||
<jruby.launch.memory>1024M</jruby.launch.memory> | ||
<version.ruby.major>2.4</version.ruby.major> | ||
<release.dir>release</release.dir> | ||
<lib.dir>lib</lib.dir> | ||
<rails.dir>${test.dir}/rails</rails.dir> | ||
<parser.dir>core/src/main/java/org/jruby/parser</parser.dir> | ||
<jruby.basedir>${basedir}/..</jruby.basedir> | ||
<rubyspec.dir>${spec.dir}/ruby</rubyspec.dir> | ||
<version.ruby.revision>58053</version.ruby.revision> | ||
<mspec.dir>${spec.dir}/mspec</mspec.dir> | ||
<build.date>${maven.build.timestamp}</build.date> | ||
<main.basedir>${project.parent.basedir}</main.basedir> | ||
<test.results.dir>${build.dir}/test-results</test.results.dir> | ||
<prawn.stable.version>0.4.1</prawn.stable.version> | ||
<mspec.tar.file>${build.dir}/mspec.tgz</mspec.tar.file> | ||
<build.lib.dir>test/target</build.lib.dir> | ||
<jmh.version>1.19</jmh.version> | ||
<rake.args></rake.args> | ||
<test.dir>test</test.dir> | ||
<jflex.bin>jflex</jflex.bin> | ||
<jruby.win32ole.gem>jruby-win32ole</jruby.win32ole.gem> | ||
<mspec.bin>${mspec.dir}/bin/mspec</mspec.bin> | ||
<jruby.gem.home>lib/ruby/gems/shared</jruby.gem.home> | ||
<test.classes.dir>${test.dir}/target/test-classes</test.classes.dir> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jruby</groupId> | ||
<artifactId>jruby-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<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> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-core-benchmarks</artifactId> | ||
<version>${jmh.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<encoding>utf-8</encoding> | ||
<debug>true</debug> | ||
<verbose>true</verbose> | ||
<fork>true</fork> | ||
<compilerArgs> | ||
<arg>-J-Xmx1G</arg> | ||
</compilerArgs> | ||
<showWarnings>true</showWarnings> | ||
<showDeprecation>true</showDeprecation> | ||
<source>${base.java.version}</source> | ||
<source>1.7</source> | ||
<target>${base.javac.version}</target> | ||
<target>1.7</target> | ||
<useIncrementalCompilation>false</useIncrementalCompilation> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>create jruby-benchmark.jar</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<outputFile>${project.build.directory}/jruby-benchmark.jar</outputFile> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>org.openjdk.jmh.Main</mainClass> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
127 changes: 127 additions & 0 deletions
127
bench/src/main/java/org/jruby/benchmark/ArrayCopyBenchmark.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,127 @@ | ||
package org.jruby.benchmark; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.jruby.util.ArraySupport; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OperationsPerInvocation; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
|
||
@Warmup(iterations = 3, time = 500, timeUnit = TimeUnit.MILLISECONDS) | ||
@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) | ||
@Fork(1) | ||
@BenchmarkMode(Mode.Throughput) | ||
@OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
@State(Scope.Thread) | ||
public class ArrayCopyBenchmark { | ||
|
||
private static final int INVOCATIONS = 100_000_000; | ||
|
||
private static final String[] arr0 = new String[0]; | ||
private static final Object[] arr1 = {"obj"}; | ||
private static final Object[] arr2 = {1, 2}; | ||
private static final Object[] arr3 = {1, 2, null}; | ||
private static final Object[] arr4 = {1, 2, 3, 4}; | ||
private static final Object[] arr5 = {1, 2, null, 4, null}; | ||
|
||
private static final String[] dst0 = {}; | ||
private static final Object[] dst1 = new Object[1]; | ||
private static final Object[] dst2 = new Object[3]; | ||
private static final Object[] dst3 = {1, 2, null}; | ||
private static final Object[] dst4 = {1, 2, null, 4, null}; | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchSystemCopy0() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
System.arraycopy(arr0, 0, dst0, 0, arr0.length); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchSystemCopy1() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
System.arraycopy(arr1, 0, dst1, 0, arr1.length); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchSystemCopy2() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
System.arraycopy(arr2, 0, dst2, 0, arr2.length); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchSystemCopy3() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
System.arraycopy(arr3, 0, dst3, 0, arr3.length); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchSystemCopy4() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
System.arraycopy(arr4, 0, dst4, 0, arr4.length); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchSystemCopy5() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
System.arraycopy(arr5, 0, new Object[6], 1, arr5.length); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchUtilsCopy0() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
ArraySupport.copy(arr0, dst0, 0, arr0.length); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchUtilsCopy1() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
ArraySupport.copy(arr1, dst1, 0, arr1.length); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchUtilsCopy2() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
ArraySupport.copy(arr2, dst2, 0, arr2.length); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchUtilsCopy3() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
ArraySupport.copy(arr3, dst3, 0, arr3.length); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@OperationsPerInvocation(INVOCATIONS) | ||
public void benchUtilsCopy4() { | ||
for (int i = 0; i < INVOCATIONS; i++) { | ||
ArraySupport.copy(arr4, dst4, 0, arr4.length); | ||
} | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.