MCPcopy Create free account
hub / github.com/nodejs/undici / printResults

Function printResults

benchmarks/benchmark-https.js:139–176  ·  view source on GitHub ↗
(results)

Source from the content-addressed store, hash-verified

137}
138
139function printResults (results) {
140 // Sort results by least performant first, then compare relative performances and also printing padding
141 let last
142
143 const rows = Object.entries(results)
144 // If any failed, put on the top of the list, otherwise order by mean, ascending
145 .sort((a, b) => (!a[1].success ? -1 : b[1].mean - a[1].mean))
146 .map(([name, result]) => {
147 if (!result.success) {
148 return {
149 Tests: name,
150 Samples: result.size,
151 Result: 'Errored',
152 Tolerance: 'N/A',
153 'Difference with Slowest': 'N/A'
154 }
155 }
156
157 // Calculate throughput and relative performance
158 const { size, mean, standardError } = result
159 const relative = last !== 0 ? (last / mean - 1) * 100 : 0
160
161 // Save the slowest for relative comparison
162 if (typeof last === 'undefined') {
163 last = mean
164 }
165
166 return {
167 Tests: name,
168 Samples: size,
169 Result: `${((parallelRequests * 1e9) / mean).toFixed(2)} req/sec`,
170 Tolerance: `± ${((standardError / mean) * 100).toFixed(2)} %`,
171 'Difference with slowest': relative > 0 ? `+ ${relative.toFixed(2)} %` : '-'
172 }
173 })
174
175 return console.table(rows)
176}
177
178const experiments = {
179 'https - no keepalive' () {

Callers 1

mainFunction · 0.70

Calls 2

mapMethod · 0.80
entriesMethod · 0.45

Tested by

no test coverage detected