summaryrefslogtreecommitdiffstats
path: root/go/snowflake_bench_test.go
diff options
context:
space:
mode:
authorEthan Werner <mail@ethanwerner.com>2026-08-07 17:17:32 +0400
committerEthan Werner <mail@ethanwerner.com>2026-08-07 17:17:32 +0400
commite4e84c7aad9fb887150ba1fcfaf64463765419c9 (patch)
treecdafa934aa61d8b646435d2a7b4ed0d7ac5c9f55 /go/snowflake_bench_test.go
parente0f9cc69f9f7f524610d65b288eecdbf2ad958d6 (diff)
javascript portHEADmaster
Diffstat (limited to 'go/snowflake_bench_test.go')
-rw-r--r--go/snowflake_bench_test.go65
1 files changed, 65 insertions, 0 deletions
diff --git a/go/snowflake_bench_test.go b/go/snowflake_bench_test.go
new file mode 100644
index 0000000..ffad399
--- /dev/null
+++ b/go/snowflake_bench_test.go
@@ -0,0 +1,65 @@
+package snowflake
+
+import "testing"
+
+var benchmarkSnowflake = New()
+
+func BenchmarkNew(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ New()
+ }
+}
+
+func BenchmarkSnowflake_String(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ benchmarkSnowflake.String()
+ }
+}
+
+func BenchmarkFromString(b *testing.B) {
+ s := benchmarkSnowflake.String()
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ FromString(s)
+ }
+}
+
+func BenchmarkSnowflake_Hex(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ benchmarkSnowflake.Hex()
+ }
+}
+
+func BenchmarkFromHex(b *testing.B) {
+ h := benchmarkSnowflake.Hex()
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ FromHex(h)
+ }
+}
+
+func BenchmarkMarshalJSON(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ benchmarkSnowflake.MarshalJSON()
+ }
+}
+
+func BenchmarkMarshalText(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ benchmarkSnowflake.MarshalText()
+ }
+}
+
+func BenchmarkValue(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ benchmarkSnowflake.Value()
+ }
+}