Added benchmark for Commaf
Spoiler: It's kind of slow. But at least there's some idea how slow
now.
diff --git a/comma_test.go b/comma_test.go
index 1386bd1..49040fb 100644
--- a/comma_test.go
+++ b/comma_test.go
@@ -42,6 +42,7 @@
{"1,000", Commaf(1000), "1,000"},
{"10,000", Commaf(10000), "10,000"},
{"100,000", Commaf(100000), "100,000"},
+ {"834,142.32", Commaf(834142.32), "834,142.32"},
{"10,000,000", Commaf(10000000), "10,000,000"},
{"10,100,000", Commaf(10100000), "10,100,000"},
{"10,010,000", Commaf(10010000), "10,010,000"},
@@ -68,6 +69,12 @@
}
}
+func BenchmarkCommaf(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ Commaf(1234567890.83584)
+ }
+}
+
func BenchmarkBigCommas(b *testing.B) {
for i := 0; i < b.N; i++ {
BigComma(big.NewInt(1234567890))