Skip to content

Instantly share code, notes, and snippets.

@shipilev
Last active August 29, 2015 14:00
Show Gist options
  • Save shipilev/11233952 to your computer and use it in GitHub Desktop.
Save shipilev/11233952 to your computer and use it in GitHub Desktop.
StringToUTF8 run
https://github.com/shipilev/benchmarks-scratch/blob/master/src/main/java/org/sample/StringToUTF8.java
It is always prudent to verify "sample" mode with "avgt", because timestamping overhead/accuracy
might skew the results in "sample".
Benchmark (length) Mode Samples Mean Mean error Units
o.s.StringToUTF8.getBytesViaWriter 1 avgt 5 1.301 0.198 us/op
o.s.StringToUTF8.getBytesViaWriter 10 avgt 5 1.287 0.048 us/op
o.s.StringToUTF8.getBytesViaWriter 100 avgt 5 1.605 0.240 us/op
o.s.StringToUTF8.getBytesViaWriter 1000 avgt 5 4.727 0.766 us/op
o.s.StringToUTF8.getBytesViaWriter 10000 avgt 5 53.793 0.612 us/op
o.s.StringToUTF8.getBytesViaWriter 100000 avgt 5 565.192 4.473 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 1 avgt 5 1.244 0.014 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 10 avgt 5 1.284 0.153 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 100 avgt 5 1.560 0.257 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 1000 avgt 5 4.591 0.153 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 10000 avgt 5 44.583 2.669 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 100000 avgt 5 533.694 10.248 us/op
o.s.StringToUTF8.getBytesWithCharset 1 avgt 5 0.086 0.002 us/op
o.s.StringToUTF8.getBytesWithCharset 10 avgt 5 0.100 0.023 us/op
o.s.StringToUTF8.getBytesWithCharset 100 avgt 5 0.335 0.016 us/op
o.s.StringToUTF8.getBytesWithCharset 1000 avgt 5 2.996 0.074 us/op
o.s.StringToUTF8.getBytesWithCharset 10000 avgt 5 34.890 2.401 us/op
o.s.StringToUTF8.getBytesWithCharset 100000 avgt 5 419.024 17.635 us/op
o.s.StringToUTF8.getBytesWithString 1 avgt 5 0.077 0.005 us/op
o.s.StringToUTF8.getBytesWithString 10 avgt 5 0.098 0.042 us/op
o.s.StringToUTF8.getBytesWithString 100 avgt 5 0.332 0.050 us/op
o.s.StringToUTF8.getBytesWithString 1000 avgt 5 3.052 0.201 us/op
o.s.StringToUTF8.getBytesWithString 10000 avgt 5 35.224 4.952 us/op
o.s.StringToUTF8.getBytesWithString 100000 avgt 5 427.088 14.454 us/op
o.s.StringToUTF8.getBytesViaWriter 1 sample 1098609 1.310 0.013 us/op
o.s.StringToUTF8.getBytesViaWriter 10 sample 1071541 1.344 0.012 us/op
o.s.StringToUTF8.getBytesViaWriter 100 sample 880527 1.647 0.014 us/op
o.s.StringToUTF8.getBytesViaWriter 1000 sample 250066 5.943 0.056 us/op
o.s.StringToUTF8.getBytesViaWriter 10000 sample 26847 55.393 0.509 us/op
o.s.StringToUTF8.getBytesViaWriter 100000 sample 2578 575.954 6.261 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 1 sample 1041171 1.383 0.012 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 10 sample 1093802 1.316 0.013 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 100 sample 909047 1.594 0.021 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 1000 sample 305822 4.843 0.042 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 10000 sample 28035 53.000 0.521 us/op
o.s.StringToUTF8.getBytesViaWriter_NoCopy 100000 sample 2759 537.709 4.630 us/op
o.s.StringToUTF8.getBytesWithCharset 1 sample 4894209 0.126 0.002 us/op
o.s.StringToUTF8.getBytesWithCharset 10 sample 4000071 0.151 0.003 us/op
o.s.StringToUTF8.getBytesWithCharset 100 sample 3553554 0.373 0.004 us/op
o.s.StringToUTF8.getBytesWithCharset 1000 sample 503716 2.919 0.025 us/op
o.s.StringToUTF8.getBytesWithCharset 10000 sample 42491 35.008 0.354 us/op
o.s.StringToUTF8.getBytesWithCharset 100000 sample 3478 427.627 4.218 us/op
o.s.StringToUTF8.getBytesWithString 1 sample 5172680 0.119 0.002 us/op
o.s.StringToUTF8.getBytesWithString 10 sample 4398066 0.141 0.002 us/op
o.s.StringToUTF8.getBytesWithString 100 sample 3505160 0.379 0.004 us/op
o.s.StringToUTF8.getBytesWithString 1000 sample 505012 2.912 0.038 us/op
o.s.StringToUTF8.getBytesWithString 10000 sample 42087 35.315 0.318 us/op
o.s.StringToUTF8.getBytesWithString 100000 sample 3463 428.805 3.871 us/op
Note that there are lots of timestamps, which would probably be problematic with multithreaded runs.
After http://hg.openjdk.java.net/code-tools/jmh/rev/cde312963a3d promotes to released version, it would
be much less of a problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment