Utils
Collections of utility functions for easybench.
ResultType
Bases: TypedDict
Type of benchmark result.
Source code in easybench/utils.py
16 17 18 19 20 21 | |
StatType
Bases: TypedDict
Type of benchmark statistics.
Source code in easybench/utils.py
24 25 26 27 28 29 30 31 | |
calculate_statistics(results)
Calculate statistics from benchmark results.
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
results
|
ResultsType
|
Dictionary of benchmark results |
必須 |
戻り値:
| タイプ | デスクリプション |
|---|---|
StatsType
|
Dictionary of calculated statistics |
ソースコード位置: easybench/utils.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
get_bench_env()
Collect environment information relevant to benchmarking.
戻り値:
| タイプ | デスクリプション |
|---|---|
dict[str, Any]
|
Dictionary containing benchmark-relevant environment details |
ソースコード位置: easybench/utils.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
measure_timer_overhead(iterations=1000000)
Measure the overhead of the time.perf_counter() function.
ソースコード位置: easybench/utils.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
visual_ljust(text, width, fillchar=' ')
Ljust for visual width.
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
text
|
str
|
The input string to pad. |
必須 |
width
|
int
|
Target visual width. |
必須 |
fillchar
|
str
|
Character used for padding. Defaults to a space. |
' '
|
戻り値:
| 名前 | タイプ | デスクリプション |
|---|---|---|
str |
str
|
Padded string with the specified visual width. |
ソースコード位置: easybench/utils.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
visual_rjust(text, width, fillchar=' ')
Rjust for visual width.
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
text
|
str
|
The input string to pad. |
必須 |
width
|
int
|
Target visual width. |
必須 |
fillchar
|
str
|
Character used for padding. Defaults to a space. |
' '
|
戻り値:
| 名前 | タイプ | デスクリプション |
|---|---|---|
str |
str
|
Right-padded string with the specified visual width. |
ソースコード位置: easybench/utils.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
visual_width(text)
Calculate the visual width of a string.
Assuming
- Fullwidth ('F') and Wide ('W') characters count as 2.
- All other characters count as 1.
This function is useful for determining display width, especially for East Asian characters in fixed-width terminal environments.
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
text
|
str
|
The input string. |
必須 |
戻り値:
| 名前 | タイプ | デスクリプション |
|---|---|---|
int |
int
|
The total visual width of the string. |
ソースコード位置: easybench/utils.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |