Skip to content

Instantly share code, notes, and snippets.

@xtaci
Created December 30, 2025 04:17
Show Gist options
  • Select an option

  • Save xtaci/f01503b9167f9b520b8896682b67e14d to your computer and use it in GitHub Desktop.

Select an option

Save xtaci/f01503b9167f9b520b8896682b67e14d to your computer and use it in GitHub Desktop.
package main
import (
"testing"
"time"
)
func BenchmarkNow(b *testing.B) {
var now uint32
for i := 0; i < b.N; i++ {
now = currentMs()
}
_ = now
}
func currentMs() uint32 {
return uint32(time.Now().UnixNano() / int64(time.Millisecond))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment