Skip to content

Commit

Permalink
use reversed distribution in report viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Oct 31, 2024
1 parent 7eec092 commit 381bc5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion report-viewer/src/model/Distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ export class Distribution {
public splitIntoBuckets(bucketCount: BucketOptions): number[] {
const bucketArray = new Array<number>(bucketCount).fill(0)
const divisor = 100 / bucketCount
const reversedDistribution = Array.from(this._distribution).reverse()
for (let i = 99; i >= 0; i--) {
bucketArray[Math.floor(i / divisor)] += this._distribution[i]
bucketArray[Math.floor(i / divisor)] += reversedDistribution[i]
}
return bucketArray
}
Expand Down
9 changes: 5 additions & 4 deletions report-viewer/tests/unit/model/Distribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { describe, expect, it } from 'vitest'
import { Distribution } from '@/model/Distribution'

const distributionData = [
0, 7, 15, 42, 109, 225, 470, 869, 1442, 2052, 3025, 4056, 5091, 6130, 7023, 7292, 7445, 7177,
6343, 5373, 4309, 3163, 2244, 1544, 923, 493, 273, 168, 61, 31, 8, 12, 2, 1, 0, 1, 2, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0,
1, 2, 12, 8, 31, 61, 168, 273, 493, 923, 1544, 2244, 3163, 4309, 5373, 6343, 7177, 7445, 7292,
7023, 6130, 5091, 4056, 3025, 2052, 1442, 869, 470, 225, 109, 42, 15, 7, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]
const distribution = new Distribution(distributionData)

Expand All @@ -14,7 +14,8 @@ describe('Distribution', () => {
expect(distribution.splitIntoBuckets(10)).toEqual([0, 0, 0, 0, 0, 0, 26, 13209, 58955, 5231])
}),
it('get in 100 Buckets', () => {
expect(distribution.splitIntoBuckets(100)).toEqual(distributionData)
const reversedOriginal = Array.from(distributionData).reverse()
expect(distribution.splitIntoBuckets(100)).toEqual(reversedOriginal)
}),
it('get in 25 Buckets', () => {
expect(distribution.splitIntoBuckets(25)).toEqual([
Expand Down

0 comments on commit 381bc5e

Please sign in to comment.