Skip to content

Commit

Permalink
Refactor[entropy][testing][bench]: clean up test code and report allo…
Browse files Browse the repository at this point in the history
…cations
  • Loading branch information
yunginnanet committed Sep 7, 2023
1 parent 01a3dec commit 325ccd9
Showing 1 changed file with 13 additions and 57 deletions.
70 changes: 13 additions & 57 deletions entropy/entropy_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package entropy

import (
"fmt"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -136,62 +137,17 @@ func Test_RNGUint32(t *testing.T) {
RNGUint32()
}

func Benchmark_RandStr5(b *testing.B) {
for n := 0; n != b.N; n++ {
RandStr(5)
}
}

func Benchmark_RandStr25(b *testing.B) {
for n := 0; n != b.N; n++ {
RandStr(25)
}
}

func Benchmark_RandStr55(b *testing.B) {
for n := 0; n != b.N; n++ {
RandStr(55)
}
}

func Benchmark_RandStr500(b *testing.B) {
for n := 0; n != b.N; n++ {
RandStr(500)
}
}

func Benchmark_RandStr55555(b *testing.B) {
for n := 0; n != b.N; n++ {
RandStr(55555)
}
}

func Benchmark_RandStrWithUpper5(b *testing.B) {
for n := 0; n != b.N; n++ {
RandStrWithUpper(5)
}
}

func Benchmark_RandStrWithUpper25(b *testing.B) {
for n := 0; n != b.N; n++ {
RandStrWithUpper(25)
}
}

func Benchmark_RandStrWithUpper55(b *testing.B) {
for n := 0; n != b.N; n++ {
RandStrWithUpper(55)
}
}

func Benchmark_RandStrWithUpper500(b *testing.B) {
for n := 0; n != b.N; n++ {
RandStrWithUpper(500)
}
}

func Benchmark_RandStrWithUpper55555(b *testing.B) {
for n := 0; n != b.N; n++ {
RandStrWithUpper(55555)
func Benchmark_RandStr(b *testing.B) {
toTest := []int{5, 25, 55, 500, 55555}
for _, n := range toTest {
for i := 1; i != 5; i++ {
b.Run(fmt.Sprintf("%dchar/run%d", n, i), func(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for tn := 0; tn != b.N; tn++ {
RandStr(n)
}
})
}
}
}

0 comments on commit 325ccd9

Please sign in to comment.