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
<ivy-module version="2.0"> | |
<info organisation="psy.lob.saw" module="experiments"/> | |
<dependencies> | |
<dependency org="com.google.caliper" name="caliper" rev="0.5-rc1"> | |
<exclude name='java-allocation-instrumenter' /> | |
</dependency> | |
</dependencies> | |
</ivy-module> |
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
import java.io.BufferedReader; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.UnsupportedEncodingException; | |
import java.nio.ByteBuffer; | |
import java.nio.CharBuffer; | |
import java.nio.charset.Charset; | |
import java.nio.charset.CharsetEncoder; | |
import java.nio.charset.CoderResult; |
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
package utf8; | |
import java.io.BufferedReader; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.UnsupportedEncodingException; | |
import java.nio.ByteBuffer; | |
import java.nio.CharBuffer; | |
import java.nio.charset.Charset; |
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
0% Scenario{vm=java, trial=0, benchmark=CustomEncoder, direct=true, stringsFile=utf8.txt} 107419.06 ns; σ=1032.57 ns @ 4 trials | |
17% Scenario{vm=java, trial=0, benchmark=StringGetBytes, direct=true, stringsFile=utf8.txt} 199795.25 ns; σ=6067.76 ns @ 10 trials | |
33% Scenario{vm=java, trial=0, benchmark=CharsetEncoder, direct=true, stringsFile=utf8.txt} 278708.17 ns; σ=10344.13 ns @ 10 trials | |
50% Scenario{vm=java, trial=0, benchmark=CustomEncoder, direct=false, stringsFile=utf8.txt} 102597.54 ns; σ=3081.05 ns @ 10 trials | |
67% Scenario{vm=java, trial=0, benchmark=StringGetBytes, direct=false, stringsFile=utf8.txt} 196083.46 ns; σ=4185.70 ns @ 10 trials | |
83% Scenario{vm=java, trial=0, benchmark=CharsetEncoder, direct=false, stringsFile=utf8.txt} 185340.89 ns; σ=17881.00 ns @ 10 trials | |
benchmark direct us linear runtime | |
CustomEncoder true 107 =========== | |
CustomEncoder false 103 =========== |
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
<target name="benchmark-utf8-encoding" depends="build,download-allocation-jar" description=" run experiments"> | |
<ivy:cachepath pathid="lib.path.id" /> | |
<java classpathref="lib.path.id" classname="utf8.Utf8EncodingBenchmark" fork="true"> | |
<classpath> | |
<pathelement path="${build.dir}"/> | |
<pathelement location="${allocation.jar.file}"/> | |
</classpath> | |
<env key="ALLOCATION_JAR" value="${allocation.jar.file}"/> | |
<arg value="--measureMemory" /> | |
</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
benchmark-utf8-encoding: | |
[java] 0% Scenario{vm=java, trial=0, benchmark=CustomEncoder, direct=true, stringsFile=utf8.txt} 99842.67 ns; σ=741.65 ns @ 3 trials, allocated 0 instances for a total of 0B | |
[java] 17% Scenario{vm=java, trial=0, benchmark=StringGetBytes, direct=true, stringsFile=utf8.txt} 204718.91 ns; σ=11685.98 ns @ 10 trials, allocated 2672 instances for a total of 166024B | |
[java] 33% Scenario{vm=java, trial=0, benchmark=CharsetEncoder, direct=true, stringsFile=utf8.txt} 267964.76 ns; σ=2541.32 ns @ 3 trials, allocated 0 instances for a total of 0B | |
[java] 50% Scenario{vm=java, trial=0, benchmark=CustomEncoder, direct=false, stringsFile=utf8.txt} 102537.55 ns; σ=5065.85 ns @ 10 trials, allocated 0 instances for a total of 0B | |
[java] 67% Scenario{vm=java, trial=0, benchmark=StringGetBytes, direct=false, stringsFile=utf8.txt} 202675.42 ns; σ=6581.97 ns @ 10 trials, allocated 2672 instances for a total of 166024B | |
[java] 83% Scenario{vm=java, trial=0, benchmark=CharsetEncode |
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
public class DirectByteBufferUnalignedInLineAtomicityTests { | |
public abstract static class ByteBufferTest implements | |
Actor1_Effector1_Test<ByteBuffer, long[]> { | |
@Override | |
public ByteBuffer newState() { | |
return allocateNaughtyBuffer(getSize()); | |
} | |
abstract int getSize(); |
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
$ java -jar target/java-concurrency-torture.jar -v -time 1000 -t .*DirectByteBufferUnalignedCrossLineAtomicityTests.*LongTest | |
Java Concurrency Torture Tests | |
--------------------------------------------------------------------------------- | |
Running in forked mode... | |
Running each test for 1000ms | |
Each test does 10 internal loops | |
Look in results.html for the results | |
Running org.openjdk.concurrent.torture.tests.atomicity.crosscache.DirectByteBufferUnalignedCrossLineAtomicityTests$LongTest |
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
Running org.openjdk.concurrent.torture.tests.atomicity.buffers.DirectByteBufferUnalignedInLineAtomicityTests$LongTest | |
Executing with 2 threads x 2 groups = 4 threads | |
Iterations . | |
Observed state Occurrences Expectation Interpretation | |
[0] ( 1327957) UNKNOWN N/A | |
[-1] ( 1336273) UNKNOWN N/A |
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
Running org.openjdk.concurrent.torture.tests.atomicity.buffers.DirectByteBufferUnalignedInLineAtomicityTests$LongTest | |
Executing with 2 threads x 2 groups = 4 threads | |
Iterations . | |
Observed state Occurrences Expectation Interpretation | |
[-1] ( 2139678) UNKNOWN N/A | |
[0] ( 2397091) UNKNOWN N/A | |
[-4294967296] ( 1) UNKNOWN N/A | |
. | |
Observed state Occurrences Expectation Interpretation | |
[-1] ( 4365283) UNKNOWN N/A |