|
1 | 1 | # StringFormatter |
2 | 2 |
|
3 | 3 | A set of a ***high performance string tools*** that helps to build strings from templates and process text faster than with `fmt`!!!. |
| 4 | +Slice printing is **50% faster with 8 items** slice and **250% with 20 items** slice |
4 | 5 |
|
5 | 6 |  |
6 | 7 |  |
@@ -76,6 +77,9 @@ For more convenient lines formatting we should choose how arguments are represen |
76 | 77 | - `{0:F8}, 10.4567890 outputs -> 10.45678900` |
77 | 78 | 5. Percentage output |
78 | 79 | - `{0:P100}, 12 outputs -> 12%` |
| 80 | +6. Lists |
| 81 | + - `{0:L-}, [1,2,3] outputs -> 1-2-3` |
| 82 | + - `{0:L, }, [1,2,3] outputs -> 1, 2, 3` |
79 | 83 |
|
80 | 84 | ##### 1.2.4 Benchmarks of the Format and FormatComplex functions |
81 | 85 |
|
@@ -107,12 +111,26 @@ str := stringFormatter.MapToString(&options, "{key} : {value}", ", ") |
107 | 111 | "connectTimeout : 1000, useSsl : true, login : sa, password : sa" |
108 | 112 | ``` |
109 | 113 |
|
110 | | -#### 2.2 Benchmarks of the MapToStr function |
| 114 | +#### 2.2 Benchmarks of the MapToString function |
111 | 115 |
|
112 | 116 | * to see `MapToStr` result - `go test -bench=MapToStr -benchmem -cpu 1` |
113 | 117 |
|
114 | 118 |  |
115 | 119 |
|
| 120 | +#### 2.3 Slice to string utility |
| 121 | + |
| 122 | +`SliceToString` - function that converts slice with passed separation between items to string. |
| 123 | +```go |
| 124 | +slice := []any{100, "200", 300, "400", 500, 600, "700", 800, 1.09, "hello"} |
| 125 | +separator := "," |
| 126 | +result := stringFormatter.SliceToString(&slice, &separator) |
| 127 | +``` |
| 128 | + |
| 129 | +#### 2.4 Benchmarks of the SliceToString function |
| 130 | + |
| 131 | +`sf` is rather fast then `fmt` 2.5 times (250%) faster on slice with 20 items, see benchmark: |
| 132 | + |
| 133 | + |
116 | 134 | ### 3. Contributors |
117 | 135 |
|
118 | 136 | <a href="https://github.com/Wissance/stringFormatter/graphs/contributors"> |
|
0 commit comments