|
1 |
| -package stringFormatter |
| 1 | +package stringFormatter_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "github.com/wissance/stringFormatter" |
| 6 | + "testing" |
| 7 | +) |
| 8 | + |
| 9 | +func BenchmarkSliceToStringAdvancedWith8IntItems(b *testing.B) { |
| 10 | + slice := []any{100, 200, 300, 400, 500, 600, 700, 800} |
| 11 | + separator := "," |
| 12 | + for i := 0; i < b.N; i++ { |
| 13 | + _ = stringFormatter.SliceToString(&slice, &separator) |
| 14 | + } |
| 15 | +} |
| 16 | + |
| 17 | +func BenchmarkSliceStandard8IntItems(b *testing.B) { |
| 18 | + slice := []any{100, 200, 300, 400, 500, 600, 700, 800} |
| 19 | + for i := 0; i < b.N; i++ { |
| 20 | + _ = fmt.Sprintf("%+q", slice) |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +func BenchmarkSliceToStringAdvanced10MixedItems(b *testing.B) { |
| 25 | + slice := []any{100, "200", 300, "400", 500, 600, "700", 800, 1.09, "hello"} |
| 26 | + separator := "," |
| 27 | + for i := 0; i < b.N; i++ { |
| 28 | + _ = stringFormatter.SliceToString(&slice, &separator) |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +func BenchmarkSliceStandard10MixedItems(b *testing.B) { |
| 33 | + slice := []any{100, "200", 300, "400", 500, 600, "700", 800, 1.09, "hello"} |
| 34 | + for i := 0; i < b.N; i++ { |
| 35 | + _ = fmt.Sprintf("%+q", slice) |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +func BenchmarkSliceToStringAdvanced20StrItems(b *testing.B) { |
| 40 | + slice := []any{"str1", "str2", "str3", "str4", "str5", "str6", "str7", "str8", "str9", "str10", |
| 41 | + "str11", "str12", "str13", "str14", "str15", "str16", "str17", "str18", "str19", "str20"} |
| 42 | + separator := "," |
| 43 | + for i := 0; i < b.N; i++ { |
| 44 | + _ = stringFormatter.SliceToString(&slice, &separator) |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +func BenchmarkSliceStandard20StrItems(b *testing.B) { |
| 49 | + slice := []any{"str1", "str2", "str3", "str4", "str5", "str6", "str7", "str8", "str9", "str10", |
| 50 | + "str11", "str12", "str13", "str14", "str15", "str16", "str17", "str18", "str19", "str20"} |
| 51 | + for i := 0; i < b.N; i++ { |
| 52 | + _ = fmt.Sprintf("%+q", slice) |
| 53 | + } |
| 54 | +} |
0 commit comments