1
0
mirror of https://github.com/golang/go synced 2024-11-14 09:00:21 -07:00
go/src/encoding
Josselin Costanzi 31c96fc227 encoding/base64: Optimize DecodeString
Optimize DecodeString for the common case where most of the input isn't
a newline or a padding character.
Also add some testcases found when fuzzing this implementation against
upstream.
Change Decode benchmark to run with different input sizes.

name                 old time/op    new time/op    delta
DecodeString/2-4       71.5ns ± 4%    70.0ns ± 6%     ~     (p=0.246 n=5+5)
DecodeString/4-4        112ns ±25%      91ns ± 2%     ~     (p=0.056 n=5+5)
DecodeString/8-4        136ns ± 5%     126ns ± 5%   -7.33%  (p=0.016 n=5+5)
DecodeString/64-4       872ns ±29%     652ns ±21%  -25.23%  (p=0.032 n=5+5)
DecodeString/8192-4    90.9µs ±21%    61.0µs ±13%  -32.87%  (p=0.008 n=5+5)

name                 old speed      new speed      delta
DecodeString/2-4     56.0MB/s ± 4%  57.2MB/s ± 6%     ~     (p=0.310 n=5+5)
DecodeString/4-4     73.4MB/s ±23%  87.7MB/s ± 2%     ~     (p=0.056 n=5+5)
DecodeString/8-4     87.8MB/s ± 5%  94.8MB/s ± 5%   +7.98%  (p=0.016 n=5+5)
DecodeString/64-4     103MB/s ±24%   136MB/s ±19%  +32.63%  (p=0.032 n=5+5)
DecodeString/8192-4   122MB/s ±19%   180MB/s ±11%  +47.75%  (p=0.008 n=5+5)

Improves #19636

Change-Id: I39667f4fb682a12b3137946d017ad999553c5780
Reviewed-on: https://go-review.googlesource.com/34950
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-24 22:40:23 +00:00
..
ascii85 all: single space after period. 2016-03-02 00:13:47 +00:00
asn1 encoding/asn1: add NullBytes and NullRawValue for working with ASN.1 NULL 2017-04-24 22:23:56 +00:00
base32 all: single space after period. 2016-03-02 00:13:47 +00:00
base64 encoding/base64: Optimize DecodeString 2017-04-24 22:40:23 +00:00
binary cmd/compile/internal/ssa: combine 2 byte loads + shifts into word load + rolw 8 on AMD64 2017-02-14 22:17:08 +00:00
csv encoding/csv: document Read error behavior 2016-10-28 19:38:12 +00:00
gob all: remove redundant returns 2017-04-19 20:03:51 +00:00
hex encoding/hex: change lookup table back to string 2017-04-18 18:16:08 +00:00
json encoding/json: reduce unmarshal mallocs for unmapped fields 2017-03-20 23:58:56 +00:00
pem encoding/pem: yet another fuzz fake failure 2017-04-03 18:46:56 +00:00
xml encoding/xml: unmarshal allow empty, non-string values 2017-03-22 23:33:36 +00:00
encoding.go all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00