internal

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: MIT Imports: 1 Imported by: 0

README

Internal Package

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

Benchmark

NowMicro() Performance

The NowMicro() function provides microsecond-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
BenchmarkDevelTime/TimeGo-10            32602948                37.16 ns/op            0 B/op          0 allocs/op
BenchmarkDevelTime/TimeGo-10            32435061                37.34 ns/op            0 B/op          0 allocs/op
BenchmarkDevelTime/TimeGo-10            32238781                36.80 ns/op            0 B/op          0 allocs/op
BenchmarkDevelTime/TimeSyscall-10       74941058                15.93 ns/op            0 B/op          0 allocs/op
BenchmarkDevelTime/TimeSyscall-10       76003882                16.11 ns/op            0 B/op          0 allocs/op
BenchmarkDevelTime/TimeSyscall-10       74914741                15.89 ns/op            0 B/op          0 allocs/op

The syscall-based implementation (TimeSyscall) is approximately 2.3x faster than the standard time.Now() approach.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NowMicro

func NowMicro() int64

NowMicro returns the current time in microseconds with microsecond precision. It is approximately twice as fast as time.Now() for high-frequency operations. This function uses syscall.Gettimeofday 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.

Jump to

Keyboard shortcuts

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