Minor improvements

This commit is contained in:
schmelczerandras 2020-09-16 22:02:50 +02:00
parent dfaaa08433
commit 7bbb5f2d96
11 changed files with 93 additions and 76 deletions

View file

@ -39,7 +39,7 @@ export class Autoscaler {
const nextTarget =
floor + 1 == this.targets.length ? previousTarget : this.targets[floor + 1];
const result = {};
const result: any = {};
for (const key in this.setters) {
const previous = previousTarget[key];
const next = nextTarget[key];

View file

@ -6,7 +6,7 @@ export const getCombinations = (values: Array<Array<number>>): Array<Array<numbe
const result: Array<Array<number>> = [];
const counters = values.map((_) => 0);
const increaseCounter = (i: number) => {
const increaseCounter = (i: number): boolean => {
if (i >= counters.length) {
return false;
}

View file

@ -1,32 +0,0 @@
export function timeIt(interval = 60) {
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
let i = 0;
let previousTimes: Array<DOMHighResTimeStamp> = [];
const targetFunction = descriptor.value;
descriptor.value = function (...values) {
const start = performance.now();
targetFunction.bind(this)(...values);
const end = performance.now();
previousTimes.push(end - start);
if (i++ % interval == 0) {
previousTimes = previousTimes.sort();
/*const text = `Max: ${last(previousTimes).toFixed(
2
)} ms\n\tMedian: ${previousTimes[Math.floor(previousTimes.length / 2)].toFixed(
2
)} ms`;*/
//InfoText.modifyRecord(propertyKey, text);
previousTimes = [];
}
};
return descriptor;
};
}