INNER CODE UNIT · TypeScript
xsSorted
hasura/graphql-bench · app/queries/src/executors/k6/index.ts:288
var xsSorted = xs.map((x, ix) => [x,ix])
.filter(([x,_]) => {
let ok = x < maxValue
if (!ok) outliersRemoved++
return ok
})
xsSorted.sort((a,b) => a[0] - b[0])
// index of last element in the first half of data:
const ix1stHalfLast = xs.length/2 - 1
const bucketWidth = (xsSorted[xsSorted.length - 1][0] - xsSorted[0][0]) / numBuckets
var buckets: HistBucket[] = []
for (let gte = xsSorted[0][0] ; true ; gte+=bucketWidth) {
// Last bucket; add remaining and stop
if (buckets.length === (numBuckets-1)) {
var count1stHalf = 0
xsSorted.map( ([_,ixOrig]) => { if (ixOrig <= ix1stHalfLast) count1stHalf++ })