Documentation
¶
Index ¶
- func Calibrate()
- func CyclesToNano(cycles uint64) uint64
- func GetAffinity() ([]int, error)
- func LockOSThread()
- func PinToCore(coreID int) error
- func PreciseDuration(start, end uint64) uint64
- func RDTSC() uint64
- func RDTSCP() (tsc uint64, aux uint32)
- func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
- type NanoProfiler
- type ProfilerEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CyclesToNano ¶
CyclesToNano converts CPU cycles to nanoseconds.
func GetAffinity ¶
GetAffinity returns the CPU cores that the current thread is allowed to run on.
func LockOSThread ¶
func LockOSThread()
LockOSThread is a wrapper for runtime.LockOSThread but could be optimized with ASM if we need even lower overhead or specific CPU pinning. For now, it serves as a placeholder for the library structure.
func PinToCore ¶
PinToCore pins the current goroutine's thread to a specific CPU core. This is critical for cache locality and preventing context switches. This function calls runtime.LockOSThread() internally.
func PreciseDuration ¶
PreciseDuration returns the "clean" duration between two TSC readings.
Types ¶
type NanoProfiler ¶
type NanoProfiler struct {
// contains filtered or unexported fields
}
NanoProfiler is a zero-allocation, fixed-size path recorder.
func NewProfiler ¶
func NewProfiler(maxEntries int) *NanoProfiler
NewProfiler creates a profiler with pre-allocated entries.
func (*NanoProfiler) GetCount ¶
func (p *NanoProfiler) GetCount() uint32
GetCount returns the current number of marks.
func (*NanoProfiler) Mark ¶
func (p *NanoProfiler) Mark(name string)
Mark records a timestamp with a name. This is designed to be extremely fast.
func (*NanoProfiler) Result ¶
func (p *NanoProfiler) Result()
Result calculates and prints the duration between marks.
type ProfilerEntry ¶
ProfilerEntry is a single point of measurement.