internal

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 1 Imported by: 0

README

Internal Package

This package contains internal utilities used by the hot cache library.

Benchmark

NowNano() Performance

The NowNano() function provides nanosecond-precision timestamps with better performance than time.Now().

ok      github.com/samber/hot   0.182s
goos: darwin
goarch: arm64
pkg: github.com/samber/hot/bench
cpu: Apple M3
BenchmarkDevelTime/TimeGo-8                             10000000                35.66 ns/op            0 B/op          0 allocs/op
BenchmarkDevelTime/TimeSyscallMonotonicTime-8           10000000                37.26 ns/op            0 B/op          0 allocs/op
BenchmarkDevelTime/TimeSyscallWallTime-8                10000000                12.19 ns/op            0 B/op          0 allocs/op
BenchmarkDevelTime/TimeRuntimeMonotonicTime-8           10000000                12.38 ns/op            0 B/op          0 allocs/op

The syscall-based implementation (TimeSyscall) and runtime.nanosecond() are approximately 2.5x faster than the standard time.Now() approach.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NowNano added in v0.8.0

func NowNano() int64

NowNano returns the current time in nanoseconds. It is approximately 3 times faster than time.Now() for high-frequency operations. This function uses runtime.nanotime() for better performance.

Types

type NoCopy added in v0.2.0

type NoCopy struct{}

NoCopy may be added to structs which must not be copied after the first use. This is a compile-time safety mechanism to prevent accidental copying of structs that contain resources that should not be duplicated.

See https://golang.org/issues/8005#issuecomment-190753527 for details.

Note that it must not be embedded, due to the Lock and Unlock methods.

func (*NoCopy) Lock added in v0.2.0

func (*NoCopy) Lock()

Lock is a no-op method used by the -copylocks checker from `go vet`. This method helps the static analyzer detect potential copying issues.

func (*NoCopy) Unlock added in v0.2.0

func (*NoCopy) Unlock()

Unlock is a no-op method used by the -copylocks checker from `go vet`. This method helps the static analyzer detect potential copying issues.

Directories

Path Synopsis
container

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL