encoding/asn1: use reflect.TypeAssert to improve performance
Use "reflect.TypeAssert" can gain some performance improvements:
goos: darwin
goarch: arm64
pkg: encoding/asn1
cpu: Apple M4
│ old │ new │
│ sec/op │ sec/op vs base │
ObjectIdentifierString-10 51.48n ± 1% 49.72n ± 2% -3.41% (p=0.000 n=10)
Marshal-10 7.549µ ± 0% 7.466µ ± 1% -1.10% (p=0.000 n=10)
Unmarshal-10 1.808µ ± 0% 1.798µ ± 0% -0.58% (p=0.000 n=10)
geomean 889.0n 873.8n -1.70%
│ old │ new │
│ B/op │ B/op vs base │
ObjectIdentifierString-10 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹
Marshal-10 7.336Ki ± 0% 7.336Ki ± 0% ~ (p=1.000 n=10) ¹
Unmarshal-10 432.0 ± 0% 432.0 ± 0% ~ (p=1.000 n=10) ¹
geomean 470.0 470.0 +0.00%
¹ all samples are equal
│ old │ new │
│ allocs/op │ allocs/op vs base │
ObjectIdentifierString-10 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
Marshal-10 271.0 ± 0% 271.0 ± 0% ~ (p=1.000 n=10) ¹
Unmarshal-10 24.00 ± 0% 24.00 ± 0% ~ (p=1.000 n=10) ¹
geomean 18.67 18.67 +0.00%
¹ all samples are equal
Updates #62121
Change-Id: I139b9d0c729c36018d4e00216ab6fc8388f3b51b
GitHub-Last-Rev:
c87aae53727dd151fadf60f6d0089d7f6a805005
GitHub-Pull-Request: golang/go#75825
Reviewed-on: https://go-review.googlesource.com/c/go/+/710555
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>