-
Notifications
You must be signed in to change notification settings - Fork 431
Expand file tree
/
Copy pathbase58_bench_test.go
More file actions
56 lines (46 loc) · 1.21 KB
/
base58_bench_test.go
File metadata and controls
56 lines (46 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package solana
import (
"testing"
)
// Benchmarks for PublicKey/Signature base58 methods, which are the
// hot paths that most users hit via Stringer and JSON marshaling.
var (
benchPubkey = MustPublicKeyFromBase58("4cHoJNmLed5PBgFBezHmJkMJLEZrcTvr3aopjnYBRxUb")
benchSignature = MustSignatureFromBase58("5YBLhMBLjhAHnEPnHKLLnVwHSfXGPJMCvKAfNsiaEw2T63edrYxVFHKUxRXfP6KA1HVo7c9JZ3LAJQR72giX7Cb")
benchPubkeyStr = "4cHoJNmLed5PBgFBezHmJkMJLEZrcTvr3aopjnYBRxUb"
benchSigStr = "5YBLhMBLjhAHnEPnHKLLnVwHSfXGPJMCvKAfNsiaEw2T63edrYxVFHKUxRXfP6KA1HVo7c9JZ3LAJQR72giX7Cb"
)
func BenchmarkPublicKey_String(b *testing.B) {
pk := benchPubkey
for b.Loop() {
_ = pk.String()
}
}
func BenchmarkPublicKeyFromBase58(b *testing.B) {
for b.Loop() {
PublicKeyFromBase58(benchPubkeyStr)
}
}
func BenchmarkSignature_String(b *testing.B) {
sig := benchSignature
for b.Loop() {
_ = sig.String()
}
}
func BenchmarkSignatureFromBase58(b *testing.B) {
for b.Loop() {
SignatureFromBase58(benchSigStr)
}
}
func BenchmarkPublicKey_MarshalJSON(b *testing.B) {
pk := benchPubkey
for b.Loop() {
pk.MarshalJSON()
}
}
func BenchmarkSignature_MarshalJSON(b *testing.B) {
sig := benchSignature
for b.Loop() {
sig.MarshalJSON()
}
}