Created
January 15, 2012 06:00
-
-
Save emboss/1614643 to your computer and use it in GitHub Desktop.
Krypt Asn.1 decoding performance
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
Krypt Asn.1 decoding performance for Rubinius, JRuby and CRuby | |
****** Rubinius ****** | |
[martin@localhost krypt]$ rbx -X19 -v | |
rubinius 2.0.0dev (1.9.3 b976944f yyyy-mm-dd JI) [x86_64-unknown-linux-gnu] | |
[martin@localhost krypt]$ rbx -X19 -Ilib -I../krypt-core/lib bm/bm_asn1.rb | |
user system total real | |
Krypt::Asn1.decode String(n=1000) 0.002000 0.000000 0.002000 ( 0.002414) | |
OpenSSL::Asn1.decode String(n=1000) 0.254962 0.006999 0.261961 ( 0.508823) | |
Krypt::Asn1.decode File IO(n=1000) 0.068990 0.014998 0.083988 ( 0.266339) | |
Krypt::Asn1.decode String from File IO(n=1000) 0.094985 0.011998 0.106983 ( 0.291195) | |
OpenSSL::X509::Certificate String(n=1000) 0.064990 0.000000 0.064990 ( 0.098601) | |
Krypt::Asn1.decode String(n=10000) 0.030995 0.003000 0.033995 ( 0.040666) | |
OpenSSL::Asn1.decode String(n=10000) 2.647597 0.001000 2.648597 ( 2.692505) | |
Krypt::Asn1.decode File IO(n=10000) 0.516922 0.150977 0.667899 ( 0.979783) | |
Krypt::Asn1.decode String from File IO(n=10000) 0.769883 0.076988 0.846871 ( 1.030663) | |
OpenSSL::X509::Certificate String(n=10000) 0.561915 0.006999 0.568914 ( 0.574179) | |
Krypt::Asn1.decode String(n=100000) 0.497924 0.007999 0.505923 ( 0.511232) | |
OpenSSL::Asn1.decode String(n=100000) 33.100968 0.025996 33.126964 ( 33.436532) | |
Krypt::Asn1.decode File IO(n=100000) 5.056231 1.323799 6.380030 ( 6.438938) | |
Krypt::Asn1.decode String from File IO(n=100000) 7.448867 0.931859 8.380726 ( 8.460167) | |
OpenSSL::X509::Certificate String(n=100000) 6.113071 0.003999 6.117070 ( 6.186172) | |
Update: Rubinius, compiled with RSTRING_NOT_MODIFIED and RUBY_READONLY_STRING | |
[martin@localhost krypt]$ rbx -X19 -v | |
rubinius 2.0.0dev (1.9.3 b976944f yyyy-mm-dd JI) [x86_64-unknown-linux-gnu] | |
[martin@localhost krypt]$ rbx -X19 -Ilib -I../krypt-core/lib bm/bm_asn1.rb | |
user system total real | |
Krypt::ASN1.decode String(n=1000) 0.003999 0.001000 0.004999 ( 0.004941) | |
OpenSSL::ASN1.decode String(n=1000) 0.269959 0.004999 0.274958 ( 0.544562) | |
Krypt::ASN1.decode File IO(n=1000) 0.068989 0.016997 0.085986 ( 0.287916) | |
Krypt::ASN1.decode String from File IO(n=1000) 0.098985 0.008999 0.107984 ( 0.213540) | |
OpenSSL::X509::Certificate String(n=1000) 0.060990 0.000000 0.060990 ( 0.140927) | |
Krypt::ASN1.decode String(n=10000) 0.029996 0.002999 0.032995 ( 0.037482) | |
OpenSSL::ASN1.decode String(n=10000) 2.822571 0.002000 2.824571 ( 2.886372) | |
Krypt::ASN1.decode File IO(n=10000) 0.594909 0.117982 0.712891 ( 1.071434) | |
Krypt::ASN1.decode String from File IO(n=10000) 0.792880 0.102984 0.895864 ( 1.076525) | |
OpenSSL::X509::Certificate String(n=10000) 0.602908 0.000000 0.602908 ( 0.608807) | |
Krypt::ASN1.decode String(n=100000) 0.459930 0.009999 0.469929 ( 0.475928) ( ~ -0.08s on average! ) | |
OpenSSL::ASN1.decode String(n=100000) 35.560594 0.123982 35.684576 ( 36.061879) | |
Krypt::ASN1.decode File IO(n=100000) 5.552156 1.255809 6.807965 ( 6.891192) | |
Krypt::ASN1.decode String from File IO(n=100000) 7.920796 0.893864 8.814660 ( 8.921030) | |
OpenSSL::X509::Certificate String(n=100000) 6.520009 0.000000 6.520009 ( 6.586175) | |
Conclusion: | |
- With RSTRING_NOT_MODIFIED, operating on Strings becomes faster and is on par with CRuby. | |
- Rubinius benefits nicely from decoding stream-based vs. reading the stream at once and then decoding the resulting string | |
- Working on a File is still slower than compared to CRuby (working on that) | |
- Krypt is much faster than existing Asn.1 decoding functionality | |
****** JRuby ****** | |
[martin@localhost krypt]$ jruby -v | |
jruby 1.6.5.1 (ruby-1.8.7-p330) (2011-12-27 1bf37c2) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_02) [linux-amd64-java] | |
[martin@localhost krypt]$ jruby --1.9 -Ilib -I../krypt-core-jruby/lib bm/bm_asn1.rb | |
user system total real | |
Krypt::Asn1.decode String(n=1000) 0.071000 0.000000 0.071000 ( 0.071000) | |
OpenSSL::Asn1.decode String(n=1000) 1.693000 0.000000 1.693000 ( 1.693000) | |
Krypt::Asn1.decode File IO(n=1000) 0.315000 0.000000 0.315000 ( 0.315000) | |
Krypt::Asn1.decode String from File IO(n=1000) 0.217000 0.000000 0.217000 ( 0.217000) | |
OpenSSL::X509::Certificate String(n=1000) 0.843000 0.000000 0.843000 ( 0.843000) | |
Krypt::Asn1.decode String(n=10000) 0.223000 0.000000 0.223000 ( 0.224000) | |
OpenSSL::Asn1.decode String(n=10000) 1.312000 0.000000 1.312000 ( 1.312000) | |
Krypt::Asn1.decode File IO(n=10000) 1.155000 0.000000 1.155000 ( 1.155000) | |
Krypt::Asn1.decode String from File IO(n=10000) 0.947000 0.000000 0.947000 ( 0.947000) | |
OpenSSL::X509::Certificate String(n=10000) 1.936000 0.000000 1.936000 ( 1.936000) | |
Krypt::Asn1.decode String(n=100000) 0.294000 0.000000 0.294000 ( 0.294000) | |
OpenSSL::Asn1.decode String(n=100000) 8.022000 0.000000 8.022000 ( 8.022000) | |
Krypt::Asn1.decode File IO(n=100000) 3.465000 0.000000 3.465000 ( 3.465000) | |
Krypt::Asn1.decode String from File IO(n=100000) 3.527000 0.000000 3.527000 ( 3.527000) | |
OpenSSL::X509::Certificate String(n=100000) 9.739000 0.000000 9.739000 ( 9.739000) | |
Update: JRuby master (basically the same outcome, plain Java implementation unfortunately does not benefit from invokedynamic) | |
[martin@localhost krypt]$ jruby --1.9 -v | |
jruby 1.7.0.dev (ruby-1.9.3-p6) (2012-01-21 0d0c764) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_02) [linux-amd64-java] | |
[martin@localhost krypt]$ jruby --1.9 -Ilib -I../krypt-core-jruby/lib bm/bm_asn1.rb | |
user system total real | |
Krypt::Asn1.decode String(n=1000) 0.096000 0.000000 0.096000 ( 0.093000) | |
OpenSSL::Asn1.decode String(n=1000) 1.926000 0.000000 1.926000 ( 1.926000) | |
Krypt::Asn1.decode File IO(n=1000) 0.389000 0.000000 0.389000 ( 0.389000) | |
Krypt::Asn1.decode String from File IO(n=1000) 0.316000 0.000000 0.316000 ( 0.316000) | |
OpenSSL::X509::Certificate String(n=1000) 0.724000 0.000000 0.724000 ( 0.724000) | |
Krypt::Asn1.decode String(n=10000) 0.197000 0.000000 0.197000 ( 0.197000) | |
OpenSSL::Asn1.decode String(n=10000) 1.406000 0.000000 1.406000 ( 1.406000) | |
Krypt::Asn1.decode File IO(n=10000) 1.386000 0.000000 1.386000 ( 1.386000) | |
Krypt::Asn1.decode String from File IO(n=10000) 0.913000 0.000000 0.913000 ( 0.913000) | |
OpenSSL::X509::Certificate String(n=10000) 2.139000 0.000000 2.139000 ( 2.139000) | |
Krypt::Asn1.decode String(n=100000) 0.296000 0.000000 0.296000 ( 0.297000) | |
OpenSSL::Asn1.decode String(n=100000) 8.445000 0.000000 8.445000 ( 8.445000) | |
Krypt::Asn1.decode File IO(n=100000) 4.900000 0.000000 4.900000 ( 4.900000) | |
Krypt::Asn1.decode String from File IO(n=100000) 4.740000 0.000000 4.740000 ( 4.740000) | |
OpenSSL::X509::Certificate String(n=100000) 9.699000 0.000000 9.699000 ( 9.699000) | |
Conclusion: | |
- After warming the JVM up, this is the fastest implementation for n=100000. | |
- Decoding stream-based is a tad slower than reading the stream at once and then decoding the resulting string. | |
- Working on a File is still slower than compared to CRuby (working on that) | |
- Krypt is much faster than existing Asn.1 decoding functionality | |
****** CRuby ****** | |
[martin@localhost krypt]$ ruby -v | |
ruby 2.0.0dev (2012-01-06 trunk 34220) [x86_64-linux] | |
[martin@localhost krypt]$ ruby -Ilib -I../krypt-core/lib bm/bm_asn1.rb | |
user system total real | |
Krypt::Asn1.decode String(n=1000) 0.000000 0.000000 0.000000 ( 0.001482) | |
OpenSSL::Asn1.decode String(n=1000) 0.060000 0.010000 0.070000 ( 0.068922) | |
Krypt::Asn1.decode File IO(n=1000) 0.020000 0.000000 0.020000 ( 0.017411) | |
Krypt::Asn1.decode String from File IO(n=1000) 0.010000 0.010000 0.020000 ( 0.019258) | |
OpenSSL::X509::Certificate String(n=1000) 0.030000 0.000000 0.030000 ( 0.033478) | |
Krypt::Asn1.decode String(n=10000) 0.030000 0.000000 0.030000 ( 0.028762) | |
OpenSSL::Asn1.decode String(n=10000) 0.670000 0.050000 0.720000 ( 0.726193) | |
Krypt::Asn1.decode File IO(n=10000) 0.110000 0.070000 0.180000 ( 0.179859) | |
Krypt::Asn1.decode String from File IO(n=10000) 0.140000 0.050000 0.190000 ( 0.193791) | |
OpenSSL::X509::Certificate String(n=10000) 0.370000 0.020000 0.390000 ( 0.392224) | |
Krypt::Asn1.decode String(n=100000) 0.390000 0.000000 0.390000 ( 0.395747) | |
OpenSSL::Asn1.decode String(n=100000) 6.460000 0.400000 6.860000 ( 6.914664) | |
Krypt::Asn1.decode File IO(n=100000) 1.140000 0.610000 1.750000 ( 1.772529) | |
Krypt::Asn1.decode String from File IO(n=100000) 1.330000 0.570000 1.900000 ( 1.935836) | |
OpenSSL::X509::Certificate String(n=100000) 4.060000 0.030000 4.090000 ( 4.125262) | |
Conclusion: | |
- Decoding stream-based gives some benefits over reading the stream at once and then decoding the resulting string. | |
Not as much as in Rubinius, but still noticeable. | |
- Working on a File is really fast | |
- Krypt is much faster than existing Asn.1 decoding functionality |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment