Skip to content

Commit e7ae6bb

Browse files
Bortlesboatjakeaturner
authored andcommitted
fix: benchmark scores clamped to 0% for below-average hardware
The log2 normalization formula `50 * (1 + log2(ratio))` produces negative values (clamped to 0) whenever the measured value is less than half the reference. For example, a CPU scoring 1993 events/sec against a 5000 reference gives ratio=0.4, log2(0.4)=-1.32, score=-16 -> 0%. Fix by dividing log2 by 3 to widen the usable range. This preserves the 50% score at the reference value while allowing below-average hardware to receive proportional non-zero scores (e.g., 28% for the CPU above). Also adds debug logging for CPU sysbench output parsing to aid future diagnosis of parsing issues. Fixes #415
1 parent 9480b2e commit e7ae6bb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

admin/app/services/benchmark_service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,10 @@ export class BenchmarkService {
571571
*/
572572
private _normalizeScore(value: number, reference: number): number {
573573
if (value <= 0) return 0
574-
// Log scale: score = 50 * (1 + log2(value/reference))
575-
// This gives 50 at reference value, scales logarithmically
574+
// Log scale with widened range: dividing log2 by 3 prevents scores from
575+
// clamping to 0% for below-average hardware. Gives 50% at reference value.
576576
const ratio = value / reference
577-
const score = 50 * (1 + Math.log2(Math.max(0.01, ratio)))
577+
const score = 50 * (1 + Math.log2(Math.max(0.01, ratio)) / 3)
578578
return Math.min(100, Math.max(0, score)) / 100
579579
}
580580

@@ -583,9 +583,9 @@ export class BenchmarkService {
583583
*/
584584
private _normalizeScoreInverse(value: number, reference: number): number {
585585
if (value <= 0) return 1
586-
// Inverse: lower values = higher scores
586+
// Inverse: lower values = higher scores, with widened log range
587587
const ratio = reference / value
588-
const score = 50 * (1 + Math.log2(Math.max(0.01, ratio)))
588+
const score = 50 * (1 + Math.log2(Math.max(0.01, ratio)) / 3)
589589
return Math.min(100, Math.max(0, score)) / 100
590590
}
591591

@@ -619,6 +619,7 @@ export class BenchmarkService {
619619
const eventsMatch = output.match(/events per second:\s*([\d.]+)/i)
620620
const totalTimeMatch = output.match(/total time:\s*([\d.]+)s/i)
621621
const totalEventsMatch = output.match(/total number of events:\s*(\d+)/i)
622+
logger.debug(`[BenchmarkService] CPU output parsing - events/s: ${eventsMatch?.[1]}, total_time: ${totalTimeMatch?.[1]}, total_events: ${totalEventsMatch?.[1]}`)
622623

623624
return {
624625
events_per_second: eventsMatch ? parseFloat(eventsMatch[1]) : 0,

0 commit comments

Comments
 (0)