Skip to content

Commit

Permalink
update benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
IncSW committed Aug 18, 2021
1 parent dc80d6b commit 1fadf5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Faster base64 encoding for Go, based on [Turbo-Base64](https://github.com/powtur

* Drop-in replacement of `encoding/base64`.
* _except for error messages and ignoring `\r` and `\n` in decoder._
* ~3 times faster than `encoding/base64`.
* up to 3 times faster than `encoding/base64`.
* Dependency-free.

## Install
Expand All @@ -33,16 +33,18 @@ Replace import statement from `encoding/base64` to `github.com/cristalhq/base64`

# Benchmarks

go1.17 linux/amd64, Intel i7-7700

```
std/Encode 674.7 ns/op 0 B/op 0 allocs/op
std/EncodeToString 943.3 ns/op 2014 B/op 2 allocs/op
std/Decode 747.8 ns/op 0 B/op 0 allocs/op
std/DecodeString 1012 ns/op 1792 B/op 2 allocs/op
own/Encode 215.3 ns/op 0 B/op 0 allocs/op
own/EncodeToString 354.6 ns/op 1024 B/op 1 allocs/op
own/Decode 306.6 ns/op 0 B/op 0 allocs/op
own/DecodeString 440.0 ns/op 768 B/op 1 allocs/op
std/Encode 685.3 ns/op 0 B/op 0 allocs/op
std/EncodeToString 951.8 ns/op 2048 B/op 2 allocs/op
std/Decode 803.9 ns/op 0 B/op 0 allocs/op
std/DecodeString 1061 ns/op 1792 B/op 2 allocs/op
own/Encode 217.8 ns/op 0 B/op 0 allocs/op
own/EncodeToString 353.2 ns/op 1024 B/op 1 allocs/op
own/Decode 376.3 ns/op 0 B/op 0 allocs/op
own/DecodeString 507.1 ns/op 768 B/op 1 allocs/op
```

## Documentation
Expand Down
16 changes: 0 additions & 16 deletions decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,3 @@ func BenchmarkDecoder(b *testing.B) {
}
})
}

func BenchmarkDecoder2(b *testing.B) {
b.ReportAllocs()
var err error

length := StdEncoding.DecodedLen(len(stdBase64ValueBytes))
byteResult = make([]byte, length)
b.Run("own/Decode", func(b *testing.B) {
for n := 0; n < b.N; n++ {
resultN, err = StdEncoding.Decode(byteResult, stdBase64ValueBytes)
if err != nil {
b.Fatal()
}
}
})
}

0 comments on commit 1fadf5e

Please sign in to comment.