}
static #logAverages (times: number[]): void {
- let count = times.length, sum = 0, reciprocals = 0, logarithms = 0, truncated = 0, min = 0xffff, max = 0, rate = 0
+ let count = times.length, truncatedCount = 0, truncated = 0, sum = 0, reciprocals = 0, logarithms = 0, min = Number.MAX_SAFE_INTEGER, max = 0, rate = 0
times.sort()
for (let i = 0; i < count; i++) {
sum += times[i]
logarithms += Math.log(times[i])
min = Math.min(min, times[i])
max = Math.max(max, times[i])
- if (count < 3 || (i > (count * 0.1) && i < (count * 0.9))) truncated += times[i]
+ if (count < 3 || (i > (0.1 * count) && i < (0.9 * (count - 1)))) {
+ truncated += times[i]
+ truncatedCount++
+ }
}
const averages = {
"Count (dispatches)": count,
"Total (ms)": sum,
- "Rate (d/s)": 1000 * count * 0.8 / (truncated || sum),
+ "Rate (d/s)": 1000 * truncatedCount / (truncated || sum),
"Minimum (ms)": min,
"Maximum (ms)": max,
"Arithmetic Mean (ms)": sum / count,
- "Truncated Mean (ms)": truncated / (count * 0.8),
+ "Truncated Mean (ms)": truncated / truncatedCount,
"Harmonic Mean (ms)": count / reciprocals,
"Geometric Mean (ms)": Math.exp(logarithms / count)
}
}
function average (times, type, effort) {
- let count = times.length, sum = 0, reciprocals = 0, logarithms = 0, truncated = 0, min = 0xffff, max = 0, rate = 0
+ let count = times.length, truncatedCount = 0, sum = 0, truncated = 0, reciprocals = 0, logarithms = 0, min = Number.MAX_SAFE_INTEGER, max = 0, rate = 0
times.sort()
for (let i = 0; i < count; i++) {
sum += times[i]
logarithms += Math.log(times[i])
min = Math.min(min, times[i])
max = Math.max(max, times[i])
- if (count < 3 || (i > (count * 0.1) && i < (count * 0.9))) truncated += times[i]
+ if (count < 3 || (i > (0.1 * count) && i < (0.9 * (count - 1)))) {
+ truncated += times[i]
+ truncatedCount++
+ }
}
const title = `NanoPow (${type}) | Effort: ${effort} | Dispatch: ${(0x100 * effort) ** 2} | Threads: ${8 * 8 * (0x100 * effort) ** 2}`
return {
[title]: {
count: count,
total: sum,
- rate: 1000 * count * 0.8 / (truncated || sum),
+ rate: 1000 * truncatedCount / (truncated || sum),
min: min,
max: max,
arithmetic: sum / count,
- truncated: truncated / (count * 0.8),
+ truncated: truncated / truncatedCount,
harmonic: count / reciprocals,
geometric: Math.exp(logarithms / count)
}