|
@@ -7,6 +7,8 @@ func BenchmarkBasicTranslation(b *testing.B) {
|
|
|
ut, _ := New("en", "en")
|
|
ut, _ := New("en", "en")
|
|
|
loc := ut.FindTranslator("en")
|
|
loc := ut.FindTranslator("en")
|
|
|
loc.Add("welcome", "Welcome to the site")
|
|
loc.Add("welcome", "Welcome to the site")
|
|
|
|
|
+ loc.Add("welcome-user", "Welcome to the site {0}")
|
|
|
|
|
+ loc.Add("welcome-user2", "Welcome to the site {0}, your location is {1}")
|
|
|
|
|
|
|
|
b.Run("", func(b *testing.B) {
|
|
b.Run("", func(b *testing.B) {
|
|
|
for i := 0; i < b.N; i++ {
|
|
for i := 0; i < b.N; i++ {
|
|
@@ -23,4 +25,36 @@ func BenchmarkBasicTranslation(b *testing.B) {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ b.Run("With1Param", func(b *testing.B) {
|
|
|
|
|
+ for i := 0; i < b.N; i++ {
|
|
|
|
|
+ loc.T("welcome-user", "Joeybloggs")
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ b.Run("ParallelWith1Param", func(b *testing.B) {
|
|
|
|
|
+
|
|
|
|
|
+ b.RunParallel(func(pb *testing.PB) {
|
|
|
|
|
+
|
|
|
|
|
+ for pb.Next() {
|
|
|
|
|
+ loc.T("welcome-user", "Joeybloggs")
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ b.Run("With2Param", func(b *testing.B) {
|
|
|
|
|
+ for i := 0; i < b.N; i++ {
|
|
|
|
|
+ loc.T("welcome-user2", "Joeybloggs", "/dev/tty0")
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ b.Run("ParallelWith2Param", func(b *testing.B) {
|
|
|
|
|
+
|
|
|
|
|
+ b.RunParallel(func(pb *testing.PB) {
|
|
|
|
|
+
|
|
|
|
|
+ for pb.Next() {
|
|
|
|
|
+ loc.T("welcome-user2", "Joeybloggs", "/dev/tty0")
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|