aboutsummaryrefslogtreecommitdiffstats
path: root/rlp
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-01-15 18:12:39 +0800
committerFelix Lange <fjl@twurst.com>2015-01-15 18:12:39 +0800
commit29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7 (patch)
tree98d2496f6ea4a409493328043e323c35eb2abf1c /rlp
parent552f5b2693a5d19c126a8116d36ba1f4f6cb76a1 (diff)
downloaddexon-29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7.tar
dexon-29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7.tar.gz
dexon-29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7.tar.bz2
dexon-29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7.tar.lz
dexon-29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7.tar.xz
dexon-29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7.tar.zst
dexon-29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7.zip
rlp: fix Decode benchmarks
Diffstat (limited to 'rlp')
-rw-r--r--rlp/decode_test.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/rlp/decode_test.go b/rlp/decode_test.go
index 35d8dc1fc..9142ef56d 100644
--- a/rlp/decode_test.go
+++ b/rlp/decode_test.go
@@ -8,8 +8,6 @@ import (
"math/big"
"reflect"
"testing"
-
- "github.com/ethereum/go-ethereum/ethutil"
)
func TestStreamKind(t *testing.T) {
@@ -515,7 +513,7 @@ func BenchmarkDecode(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
- var s []int
+ var s []uint
r := bytes.NewReader(enc)
if err := Decode(r, &s); err != nil {
b.Fatalf("Decode error: %v", err)
@@ -529,7 +527,7 @@ func BenchmarkDecodeIntSliceReuse(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
- var s []int
+ var s []uint
for i := 0; i < b.N; i++ {
r := bytes.NewReader(enc)
if err := Decode(r, &s); err != nil {
@@ -538,12 +536,16 @@ func BenchmarkDecodeIntSliceReuse(b *testing.B) {
}
}
-func encodeTestSlice(n int) []byte {
- s := make([]interface{}, n)
- for i := 0; i < n; i++ {
+func encodeTestSlice(n uint) []byte {
+ s := make([]uint, n)
+ for i := uint(0); i < n; i++ {
s[i] = i
}
- return ethutil.Encode(s)
+ b, err := EncodeToBytes(s)
+ if err != nil {
+ panic(fmt.Sprintf("encode error: %v", err))
+ }
+ return b
}
func unhex(str string) []byte {