github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/qpc/qpc_other.go (about)

     1  // +build !windows
     2  
     3  package qpc
     4  
     5  import (
     6  	"time"
     7  )
     8  
     9  // Now returns ticks
    10  func Now() Count {
    11  	return Count(time.Now().UnixNano())
    12  }
    13  
    14  func (a Count) Sub(b Count) Count { return a - b }
    15  
    16  func (count Count) Nanoseconds() int64 {
    17  	return int64(count)
    18  }
    19  
    20  func (count Count) Duration() time.Duration {
    21  	return time.Duration(count) * time.Nanosecond
    22  }