Skip to content

Commit

Permalink
IMPROVE index performance
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Apr 7, 2023
1 parent f5000ec commit 6c505f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 16 additions & 0 deletions orga/performance-trackings.md
Original file line number Diff line number Diff line change
Expand Up @@ -1338,3 +1338,19 @@ compareCounts: 1431962
AFTER (using custom low index):
time for "merge sorted arrays": 847.3687120079994ms
compareCounts: 1261729


## Improve getIndexableStringMonad()()

BEFORE:
91.24348497390747
86.09021002054214
89.61336600780487
87.5959959924221
87.1041649878025


AFTER (fix getNumberIndexString()):
76.63579297065735
63.062547981739044
80.47493699193001
8 changes: 3 additions & 5 deletions src/custom-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,12 @@ export function getNumberIndexString(
fieldValue = parsedLengths.maximum;
}

let str: string = '';
const nonDecimalsValueAsString = (Math.floor(fieldValue) - parsedLengths.roundedMinimum).toString();
str += nonDecimalsValueAsString.padStart(parsedLengths.nonDecimals, '0');

const splitByDecimalPoint = fieldValue.toString().split('.');
const decimalValueAsString = splitByDecimalPoint.length > 1 ? splitByDecimalPoint[1] : '0';
let str = nonDecimalsValueAsString.padStart(parsedLengths.nonDecimals, '0');

if (parsedLengths.decimals > 0) {
const splitByDecimalPoint = fieldValue.toString().split('.');
const decimalValueAsString = splitByDecimalPoint.length > 1 ? splitByDecimalPoint[1] : '0';
str += decimalValueAsString.padEnd(parsedLengths.decimals, '0');
}
return str;
Expand Down

0 comments on commit 6c505f2

Please sign in to comment.