File: benchmarks_test.go

package info (click to toggle)
golang-code.cloudfoundry-bytefmt 0.0~git20190818.854d396-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 104 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 429 bytes parent folder | download
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
package bytefmt_test

import (
	"testing"

	. "code.cloudfoundry.org/bytefmt"
)

const (
	byteSize = 1e10
	toBytes  = "\n\n\r\t10.18TiB\n\n\r\t"
)

func BenchmarkToBytes(b *testing.B) {
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		if _, err := ToBytes(toBytes); err != nil {
			b.Errorf("error: %s", err)
		}
	}
}

func BenchmarkByteSize(b *testing.B) {
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		ByteSize(byteSize)
	}
}