mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
build: modernize benchmark usage
This commit is contained in:
@@ -172,8 +172,8 @@ func BenchmarkQuickXorHash(b *testing.B) {
|
|||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
require.Equal(b, len(buf), n)
|
require.Equal(b, len(buf), n)
|
||||||
h := New()
|
h := New()
|
||||||
b.ResetTimer()
|
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
h.Reset()
|
h.Reset()
|
||||||
h.Write(buf)
|
h.Write(buf)
|
||||||
h.Sum(nil)
|
h.Sum(nil)
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ func BenchmarkCheckParents(b *testing.B) {
|
|||||||
dt.Add(o)
|
dt.Add(o)
|
||||||
}
|
}
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
for n := 0; n < b.N; n++ {
|
for b.Loop() {
|
||||||
dt.CheckParents("")
|
dt.CheckParents("")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func BenchmarkAllocFree(b *testing.B) {
|
|||||||
for _, dirty := range []bool{false, true} {
|
for _, dirty := range []bool{false, true} {
|
||||||
for size := 4096; size <= 32*1024*1024; size *= 2 {
|
for size := 4096; size <= 32*1024*1024; size *= 2 {
|
||||||
b.Run(fmt.Sprintf("%dk,dirty=%v", size>>10, dirty), func(b *testing.B) {
|
b.Run(fmt.Sprintf("%dk,dirty=%v", size>>10, dirty), func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
mem := MustAlloc(size)
|
mem := MustAlloc(size)
|
||||||
if dirty {
|
if dirty {
|
||||||
mem[0] ^= 0xFF
|
mem[0] ^= 0xFF
|
||||||
@@ -62,7 +62,7 @@ func BenchmarkAllocFreeWithLotsOfAllocations(b *testing.B) {
|
|||||||
for preAllocs := 1; preAllocs <= maxAllocs; preAllocs *= 2 {
|
for preAllocs := 1; preAllocs <= maxAllocs; preAllocs *= 2 {
|
||||||
allocs := alloc(preAllocs)
|
allocs := alloc(preAllocs)
|
||||||
b.Run(fmt.Sprintf("%d", preAllocs), func(b *testing.B) {
|
b.Run(fmt.Sprintf("%d", preAllocs), func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
mem := MustAlloc(size)
|
mem := MustAlloc(size)
|
||||||
mem[0] ^= 0xFF
|
mem[0] ^= 0xFF
|
||||||
MustFree(mem)
|
MustFree(mem)
|
||||||
@@ -90,7 +90,7 @@ func BenchmarkAllocFreeForLotsOfAllocations(b *testing.B) {
|
|||||||
}
|
}
|
||||||
for preAllocs := 1; preAllocs <= maxAllocs; preAllocs *= 2 {
|
for preAllocs := 1; preAllocs <= maxAllocs; preAllocs *= 2 {
|
||||||
b.Run(fmt.Sprintf("%d", preAllocs), func(b *testing.B) {
|
b.Run(fmt.Sprintf("%d", preAllocs), func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
allocs := alloc(preAllocs)
|
allocs := alloc(preAllocs)
|
||||||
free(allocs)
|
free(allocs)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user