• Josselin Costanzi's avatar
    encoding/base64: optimize DecodeString · 244c98fe
    Josselin Costanzi authored
    Optimize base64 decoding speed by adding 32-bits and 64-bits specialized
    methods that don't perform any error checking and fall back to the more
    complex decodeQuantum method when a non-base64 character is present.
    
    On a 64-bits cpu:
    
    name                 old time/op    new time/op     delta
    DecodeString/2-4       70.0ns ± 6%     69.2ns ± 0%     ~     (p=0.169 n=5+8)
    DecodeString/4-4       91.3ns ± 2%     80.4ns ± 0%  -11.89%  (p=0.001 n=5+10)
    DecodeString/8-4        126ns ± 5%      106ns ± 0%  -16.14%  (p=0.000 n=5+7)
    DecodeString/64-4       652ns ±21%      361ns ± 0%  -44.57%  (p=0.000 n=5+7)
    DecodeString/8192-4    61.0µs ±13%     31.5µs ± 1%  -48.38%  (p=0.001 n=5+9)
    
    name                 old speed      new speed       delta
    DecodeString/2-4     57.2MB/s ± 6%   57.7MB/s ± 2%     ~     (p=0.419 n=5+9)
    DecodeString/4-4     87.7MB/s ± 2%   99.5MB/s ± 0%  +13.45%  (p=0.001 n=5+10)
    DecodeString/8-4     94.8MB/s ± 5%  112.6MB/s ± 1%  +18.82%  (p=0.001 n=5+9)
    DecodeString/64-4     136MB/s ±19%    243MB/s ± 0%  +78.17%  (p=0.003 n=5+7)
    DecodeString/8192-4   180MB/s ±11%    347MB/s ± 1%  +92.94%  (p=0.001 n=5+9)
    
    Improves #19636
    
    Change-Id: Ic10a454851093a7e1d46ca0c140deed73535d990
    Reviewed-on: https://go-review.googlesource.com/38632
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    244c98fe
Name
Last commit
Last update
..
base64.go Loading commit data...
base64_test.go Loading commit data...
example_test.go Loading commit data...