github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/cmn/mono/mono_test.go (about)

     1  // Package mono_test contains standard vs monotonic clock benchmark
     2  /*
     3   * Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package mono_test
     6  
     7  import (
     8  	"testing"
     9  	"time"
    10  
    11  	"github.com/NVIDIA/aistore/cmn/mono"
    12  )
    13  
    14  // go test -tags=mono -bench="Fast|Std"
    15  
    16  func BenchmarkFast(b *testing.B) {
    17  	b.RunParallel(func(pb *testing.PB) {
    18  		for pb.Next() {
    19  			_ = mono.Since(mono.NanoTime())
    20  		}
    21  	})
    22  }
    23  
    24  func BenchmarkStd(b *testing.B) {
    25  	b.RunParallel(func(pb *testing.PB) {
    26  		for pb.Next() {
    27  			_ = mono.Since(time.Now().UnixNano())
    28  		}
    29  	})
    30  }