-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2,242 changed files
with
1,251 additions
and
44,156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package ut | ||
|
||
import "testing" | ||
|
||
func BenchmarkBasicTranslation(b *testing.B) { | ||
|
||
ut, _ := New("en", "en") | ||
loc := ut.FindTranslator("en") | ||
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) { | ||
for i := 0; i < b.N; i++ { | ||
loc.T("welcome") | ||
} | ||
}) | ||
|
||
b.Run("Parallel", func(b *testing.B) { | ||
|
||
b.RunParallel(func(pb *testing.PB) { | ||
|
||
for pb.Next() { | ||
loc.T("welcome") | ||
} | ||
}) | ||
}) | ||
|
||
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") | ||
} | ||
}) | ||
}) | ||
} |
Oops, something went wrong.