Skip to content

Commit 549cc12

Browse files
chore(tests): unify byte format (#896)
* chore(tests): unify byte format * Clean Up --------- Co-authored-by: Alexander Karan <47707063+AlexanderKaran@users.noreply.github.com>
1 parent b12de3c commit 549cc12

43 files changed

Lines changed: 64 additions & 52 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/docs/src/benchmarks/server-side-throughput-tests/FrameworkSSRRequestThroughputVersionCharts.astro‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import type { ChartMeasurement } from '../../lib/types'
33
import {
4-
prepareSsrRequestThroughputTestsBodySizeKbHistory,
4+
prepareSsrRequestThroughputTestsBodySizeBytesHistory,
55
prepareSsrRequestThroughputTestsLatencyMsHistory,
66
prepareSsrRequestThroughputTestsOpsPerSecHistory,
77
} from '../../lib/prepare-chart'
@@ -18,7 +18,7 @@ const { versions } = Astro.props
1818
{...prepareSsrRequestThroughputTestsOpsPerSecHistory(versions)}
1919
/>
2020
<VersionLineChart
21-
{...prepareSsrRequestThroughputTestsBodySizeKbHistory(versions)}
21+
{...prepareSsrRequestThroughputTestsBodySizeBytesHistory(versions)}
2222
/>
2323
<VersionLineChart
2424
{...prepareSsrRequestThroughputTestsLatencyMsHistory(versions)}

‎packages/docs/src/benchmarks/server-side-throughput-tests/SSRRequestThroughputBodySizeChart.astro‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import {
3-
prepareSsrRequestThroughputTestsBodySizeKbComparison,
4-
prepareSsrRequestThroughputTestsBodySizeKbMonthlyComparison,
3+
prepareSsrRequestThroughputTestsBodySizeBytesComparison,
4+
prepareSsrRequestThroughputTestsBodySizeBytesMonthlyComparison,
55
runtimeHistory,
66
ssrRequestThroughputStats,
77
} from '../../lib/prepare-chart'
@@ -11,10 +11,10 @@ import ViewSwitcher from '../../components/ViewSwitcher.astro'
1111
import ComparisonBarChart from '../../components/ComparisonBarChart.astro'
1212
import ComparisonLineChart from '../../components/ComparisonLineChart.astro'
1313
14-
const bar = prepareSsrRequestThroughputTestsBodySizeKbComparison(
14+
const bar = prepareSsrRequestThroughputTestsBodySizeBytesComparison(
1515
ssrRequestThroughputStats,
1616
)
17-
const line = prepareSsrRequestThroughputTestsBodySizeKbMonthlyComparison(
17+
const line = prepareSsrRequestThroughputTestsBodySizeBytesMonthlyComparison(
1818
runtimeHistory,
1919
ssrRequestThroughputStats,
2020
)

‎packages/docs/src/lib/chart-measurements.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -635,31 +635,31 @@ export function prepareSsrRequestThroughputTestsOpsPerSecMonthlyComparison(
635635
)
636636
}
637637

638-
export function prepareSsrRequestThroughputTestsBodySizeKbHistory(
638+
export function prepareSsrRequestThroughputTestsBodySizeBytesHistory(
639639
records: readonly ChartMeasurement[],
640640
): VersionLineChartPayload {
641641
return history(
642642
metricCatalogue['ssrRequestThroughput.bodySize'],
643643
records.map((record) => ({
644644
record,
645-
value: finiteValue(record.ssrRequestThroughput?.bodySize?.value),
645+
value: finiteValue(record.ssrRequestThroughput?.bodySize?.value, 1024),
646646
})),
647647
)
648648
}
649649

650-
export function prepareSsrRequestThroughputTestsBodySizeKbComparison(
650+
export function prepareSsrRequestThroughputTestsBodySizeBytesComparison(
651651
records: readonly ChartMeasurement[],
652652
): PreparedComparisonChart {
653653
return comparison(
654654
metricCatalogue['ssrRequestThroughput.bodySize'],
655655
records.map((record) => ({
656656
record,
657-
value: finiteValue(record.ssrRequestThroughput?.bodySize?.value),
657+
value: finiteValue(record.ssrRequestThroughput?.bodySize?.value, 1024),
658658
})),
659659
)
660660
}
661661

662-
export function prepareSsrRequestThroughputTestsBodySizeKbMonthlyComparison(
662+
export function prepareSsrRequestThroughputTestsBodySizeBytesMonthlyComparison(
663663
history: readonly ChartMeasurement[],
664664
latest: readonly ChartMeasurement[],
665665
now?: Date,
@@ -668,7 +668,7 @@ export function prepareSsrRequestThroughputTestsBodySizeKbMonthlyComparison(
668668
metricCatalogue['ssrRequestThroughput.bodySize'],
669669
history,
670670
latest,
671-
(record) => finiteValue(record.ssrRequestThroughput?.bodySize?.value),
671+
(record) => finiteValue(record.ssrRequestThroughput?.bodySize?.value, 1024),
672672
now,
673673
)
674674
}

‎packages/docs/src/lib/chart.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export function formatChartValue(
1414
case 'mb':
1515
formatted = `${value.toFixed(2)} MB`
1616
break
17+
case 'kib':
18+
formatted = `${value.toFixed(2)} KiB`
19+
break
1720
case 'kb':
1821
formatted = `${value.toFixed(2)} KB`
1922
break

‎packages/docs/src/lib/metrics.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export const metricCatalogue = {
9797
'ssrRequestThroughput.bodySize': {
9898
id: 'ssrRequestThroughput.bodySize',
9999
title: 'Body Size',
100-
valueFormat: 'kb',
101-
yAxisLabel: 'Kilobytes',
100+
valueFormat: 'kib',
101+
yAxisLabel: 'KiB',
102102
},
103103
'ssrRequestThroughput.latency': {
104104
id: 'ssrRequestThroughput.latency',

‎packages/docs/src/lib/prepare-table.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export const requestThroughputTableData = ssrRequestThroughputStats.flatMap(
282282
package: f.package,
283283
requestThroughput: Math.round(tests.requestThroughput).toLocaleString(),
284284
latency: `${Number(tests.latency.toFixed(3))}${tests.latencyUnit}`,
285-
bodySize: `${tests.bodySize.value} ${tests.bodySize.unit}`,
285+
bodySize: `${Number((tests.bodySize.value / 1024).toFixed(2))} KiB`,
286286
duplicationFactor: `${tests.duplicationFactor.value}x`,
287287
},
288288
]

‎packages/docs/src/lib/request-throughput.test.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { test } from 'node:test'
33
import { formatThroughput } from './result-content.ts'
44
import type { BenchmarkResult } from '@framework-performance/results/benchmark-schemas'
55
import {
6+
prepareSsrRequestThroughputTestsBodySizeBytesComparison,
67
prepareSsrRequestThroughputTestsOpsPerSecComparison,
78
prepareSsrRequestThroughputTestsLatencyMsComparison,
89
prepareSsrRequestThroughputTestsOpsPerSecHistory,
@@ -35,10 +36,19 @@ const benchmark = {
3536
},
3637
latency: { mean: 16, median: 4, min: 4, max: 40, unit: 'ms' },
3738
requests: { value: 9, unit: 'requests' },
38-
bodySize: { value: 20.5, unit: 'KiB' },
39+
bodySize: { value: 20_992, unit: 'bytes' },
3940
duplicationFactor: { value: 1.25, unit: 'ratio' },
4041
} satisfies NonNullable<BenchmarkResult['ssrThroughput']>
4142

43+
test('the response body size chart displays stored bytes in KiB', () => {
44+
const records = [
45+
{ package: 'app-astro', ssrRequestThroughput: formatThroughput(benchmark) },
46+
]
47+
const chart = prepareSsrRequestThroughputTestsBodySizeBytesComparison(records)
48+
assert.equal(chart.data[0]?.value, 20.5)
49+
assert.equal(chart.valueFormat, 'kib')
50+
})
51+
4252
test('throughput charts use the median of run means, not the mean or request median', () => {
4353
const normalized = formatThroughput(benchmark)
4454
assert.equal(normalized.requestThroughput, 100)

‎packages/docs/src/lib/types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
import type { z } from 'astro/zod'
77
import type { LineChartScaleId, LineChartTooltipId } from './line-chart-config'
88

9-
export type ChartValueFormat = 'count' | 'mb' | 'kb' | 'ms' | 's'
9+
export type ChartValueFormat = 'count' | 'mb' | 'kb' | 'kib' | 'ms' | 's'
1010

1111
export interface ChartDatum {
1212
id?: string

‎packages/results/data/astro/latest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@
519519
}
520520
},
521521
"requests": { "value": 35366, "unit": "requests" },
522-
"bodySize": { "value": 96.89, "unit": "KiB" },
522+
"bodySize": { "value": 99215, "unit": "bytes" },
523523
"duplicationFactor": { "value": 1, "unit": "ratio" }
524524
},
525525
"ssrLoad": {

‎packages/results/data/astro/versions/7.4.12.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@
519519
}
520520
},
521521
"requests": { "value": 35366, "unit": "requests" },
522-
"bodySize": { "value": 96.89, "unit": "KiB" },
522+
"bodySize": { "value": 99215, "unit": "bytes" },
523523
"duplicationFactor": { "value": 1, "unit": "ratio" }
524524
},
525525
"ssrLoad": {

0 commit comments

Comments
 (0)