AWS Developer Tools Blog

Follow up on Base64 Codec Performance

After we posted the previous blog, A Fast and Correct Base64 Codec, some readers expressed interest in getting more details about the comparison of various codecs’ performance. So this blog post is a quick follow-up with a side-by-side decode/encode performance comparison of various Base64 codec’s, including AWS SDK for Java, DataTypeConverter, Jakarta Commons Codec and Java 8.

To generate the performance data, we used the same test suite as in the previous blog, except this time we ran the tests in a Java 8 VM (instead of Java 7 as in the original blog) so as to include the Java 8-specific Base 64 codec for comparison. (The particular JVM is Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode.)

As you can see from the graph and statistics below, in terms of raw performance, the DataTypeConverter is the fastest in terms of Base64 decoding, whereas Java 8 is the clear winner in terms of Base64 encoding. However, as explained in the previous blog, decoding speed is not the only factor in selecting the Base64 decoder for use in the AWS SDK for Java, but also security and correctness.

Hope you find this information useful.

Decoder Performance

Base 64 decoder speed density plots

                (Decoder performance statistics associated with the graph generated via R above.)
                              vars      n  mean   sd median trimmed  mad  min max range skew  kurtosis  se
Commons                1 1000 24.28 4.36     24        23.88  4.45  18   50    32      1.06     2.12    0.14
DataTypeConverter 2 1000  8.51 2.55        8          8.14  1.48    6   51    45      5.83    79.84   0.08
Java8                       3 1000 11.43 2.96     11         11.11  2.97    8   60    52      4.85    70.63   0.09
SDK                         4 1000 13.77 2.80     13        13.47  2.97  10   39    29      2.27    13.50   0.09

    Commons      DataTypeConverter     Java8            SDK       
 Min.     :18.00     Min.   :  6.000           Min.      : 8.00    Min.     :10.00  
 1st Qu.:21.00   1st Qu. : 7.000           1st Qu.  : 9.00   1st Qu. :12.00  
 Median :24.00  Median : 8.000           Median :11.00  Median :13.00  
 Mean   :24.28   Mean   :  8.506           Mean   :11.43   Mean   :13.77  
 3rd Qu.:27.00   3rd Qu.:  9.000           3rd Qu.:13.00   3rd Qu.:16.00  
 Max.    :50.00    Max.    :51.000           Max.    :60.00   Max.    :39.00  
 

Encoder Performance

Base 64 encoder speed density plots
 

                  (Encoder performance statistics associated with the graph generated via R above.)
                                 vars    n  mean   sd median trimmed  mad min max range  skew kurtosis   se
Commons                 1 1000 21.94 3.68     21   21.46       2.97  17  69     52      2.99     27.04  0.12
DataTypeConverter  2 1000 11.88 9.70     10    0.91        1.48    7 148   141    11.06   127.96  0.31
Java8                        3 1000  7.22  3.56      6     6.91       1.48    5   99     94    18.08   447.36  0.11
SDK                          4 1000 11.84 9.66     10   10.84       1.48    5 139   134    10.52   114.39  0.31

    Commons      DataTypeConverter       Java8                 SDK        
 Min.      :17.00   Min.      :   7.00    Min.      : 5.000   Min.      :    5.00  
 1st Qu. :19.00   1st Qu. : 10.00    1st Qu.  : 6.000   1st Qu. :  10.00  
 Median :21.00   Median : 10.00    Median : 6.000   Median :  10.00  
 Mean    :21.94   Mean    : 11.88    Mean    : 7.225   Mean   :  11.84  
 3rd Qu. :24.00   3rd Qu. : 12.00    3rd Qu. : 8.000   3rd Qu.:  12.00  
 Max.     :69.00   Max.     :148.00    Max.    :99.000   Max.    :139.00