forked from TrueCloudLab/frostfs-node
[#381] *: Move to sync/atomic
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
ff570847a4
commit
4b768fd115
21 changed files with 77 additions and 64 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -15,7 +16,6 @@ import (
|
|||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
objecttest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/atomic"
|
||||
)
|
||||
|
||||
func prepareObjects(t testing.TB, n int) []*objectSDK.Object {
|
||||
|
@ -49,13 +49,15 @@ func BenchmarkPut(b *testing.B) {
|
|||
// Ensure the benchmark is bound by CPU and not waiting batch-delay time.
|
||||
b.SetParallelism(1)
|
||||
|
||||
index := atomic.NewInt64(-1)
|
||||
var index atomic.Int64
|
||||
index.Store(-1)
|
||||
|
||||
objs := prepareObjects(b, b.N)
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
if err := metaPut(db, objs[index.Inc()], nil); err != nil {
|
||||
if err := metaPut(db, objs[index.Add(1)], nil); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -65,12 +67,13 @@ func BenchmarkPut(b *testing.B) {
|
|||
db := newDB(b,
|
||||
meta.WithMaxBatchDelay(time.Millisecond*10),
|
||||
meta.WithMaxBatchSize(1))
|
||||
index := atomic.NewInt64(-1)
|
||||
var index atomic.Int64
|
||||
index.Store(-1)
|
||||
objs := prepareObjects(b, b.N)
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err := metaPut(db, objs[index.Inc()], nil); err != nil {
|
||||
if err := metaPut(db, objs[index.Add(1)], nil); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue