Skip to content

Commit

Permalink
feat: add median to --output-json (#5745)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joristdh authored May 27, 2024
1 parent b7438b9 commit 0766b7f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/vitest/src/node/reporters/benchmark/table/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ interface FormattedBenchmarkGroup {
export type FormattedBenchmarkResult = Omit<BenchmarkResult, 'samples'> & {
id: string
sampleCount: number
median: number
}

function createFormattedBenchamrkReport(files: File[]) {
Expand All @@ -145,6 +146,9 @@ function createFormattedBenchamrkReport(files: File[]) {
benchmarks.push({
id: t.id,
sampleCount: samples.length,
median: samples.length % 2
? samples[Math.floor(samples.length / 2)]
: (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2,
...rest,
})
}
Expand Down

0 comments on commit 0766b7f

Please sign in to comment.