2015-05-01 19:41:58 +02:00
|
|
|
// Copyright (c) 2013-2014 The btcsuite developers
|
2014-12-22 17:44:01 +01:00
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package base58_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
2021-09-10 22:30:39 +02:00
|
|
|
"github.com/lbryio/lbcutil/base58"
|
2014-12-22 17:44:01 +01:00
|
|
|
)
|
|
|
|
|
2020-09-10 16:54:35 +02:00
|
|
|
var (
|
|
|
|
raw5k = bytes.Repeat([]byte{0xff}, 5000)
|
|
|
|
raw100k = bytes.Repeat([]byte{0xff}, 100*1000)
|
|
|
|
encoded5k = base58.Encode(raw5k)
|
|
|
|
encoded100k = base58.Encode(raw100k)
|
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkBase58Encode_5K(b *testing.B) {
|
|
|
|
b.SetBytes(int64(len(raw5k)))
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
base58.Encode(raw5k)
|
|
|
|
}
|
|
|
|
}
|
2014-12-22 17:44:01 +01:00
|
|
|
|
2020-09-10 16:54:35 +02:00
|
|
|
func BenchmarkBase58Encode_100K(b *testing.B) {
|
|
|
|
b.SetBytes(int64(len(raw100k)))
|
2014-12-22 17:44:01 +01:00
|
|
|
for i := 0; i < b.N; i++ {
|
2020-09-10 16:54:35 +02:00
|
|
|
base58.Encode(raw100k)
|
2014-12-22 17:44:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-10 16:54:35 +02:00
|
|
|
func BenchmarkBase58Decode_5K(b *testing.B) {
|
|
|
|
b.SetBytes(int64(len(encoded5k)))
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
base58.Decode(encoded5k)
|
|
|
|
}
|
|
|
|
}
|
2014-12-22 17:44:01 +01:00
|
|
|
|
2020-09-10 16:54:35 +02:00
|
|
|
func BenchmarkBase58Decode_100K(b *testing.B) {
|
|
|
|
b.SetBytes(int64(len(encoded100k)))
|
2014-12-22 17:44:01 +01:00
|
|
|
for i := 0; i < b.N; i++ {
|
2020-09-10 16:54:35 +02:00
|
|
|
base58.Decode(encoded100k)
|
2014-12-22 17:44:01 +01:00
|
|
|
}
|
|
|
|
}
|