debug: more profiling for Automod
This commit is contained in:
parent
53d7491c1b
commit
f582640e8e
2 changed files with 28 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
import { Profiler } from "knub/dist/Profiler";
|
||||
import { performance } from "perf_hooks";
|
||||
import { SECONDS } from "../utils";
|
||||
|
||||
export const startProfiling = (profiler: Profiler, key: string) => {
|
||||
const startTime = performance.now();
|
||||
|
@ -7,3 +8,21 @@ export const startProfiling = (profiler: Profiler, key: string) => {
|
|||
profiler.addDataPoint(key, performance.now() - startTime);
|
||||
};
|
||||
};
|
||||
|
||||
export const calculateBlocking = (coarseness = 10) => {
|
||||
let last = performance.now();
|
||||
let result = 0;
|
||||
const interval = setInterval(() => {
|
||||
const now = performance.now();
|
||||
const blockedTime = Math.max(0, now - last - coarseness);
|
||||
result += blockedTime;
|
||||
last = now;
|
||||
}, coarseness);
|
||||
|
||||
setTimeout(() => clearInterval(interval), 10 * SECONDS);
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
return result;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue