2021-02-08 17:39:09 +01:00
|
|
|
import { log } from './log';
|
2020-12-08 15:00:44 +01:00
|
|
|
|
2021-02-08 17:39:09 +01:00
|
|
|
export const data = {};
|
2020-11-01 19:07:53 +01:00
|
|
|
|
2021-02-13 15:16:41 +01:00
|
|
|
export function run(name: string, raw: any) {
|
2021-02-08 17:39:09 +01:00
|
|
|
if (!raw || !raw.kernels) return;
|
2020-11-01 19:07:53 +01:00
|
|
|
const maxResults = 5;
|
2021-02-08 17:39:09 +01:00
|
|
|
const time = raw.kernels
|
2020-11-01 19:07:53 +01:00
|
|
|
.filter((a) => a.kernelTimeMs > 0)
|
|
|
|
.reduce((a, b) => a += b.kernelTimeMs, 0);
|
2021-02-08 17:39:09 +01:00
|
|
|
const slowest = raw.kernels
|
2020-11-01 19:07:53 +01:00
|
|
|
.map((a, i) => { a.id = i; return a; })
|
|
|
|
.filter((a) => a.kernelTimeMs > 0)
|
|
|
|
.sort((a, b) => b.kernelTimeMs - a.kernelTimeMs);
|
2021-02-08 17:39:09 +01:00
|
|
|
const largest = raw.kernels
|
2020-11-01 19:07:53 +01:00
|
|
|
.map((a, i) => { a.id = i; return a; })
|
|
|
|
.filter((a) => a.totalBytesSnapshot > 0)
|
|
|
|
.sort((a, b) => b.totalBytesSnapshot - a.totalBytesSnapshot);
|
|
|
|
if (slowest.length > maxResults) slowest.length = maxResults;
|
|
|
|
if (largest.length > maxResults) largest.length = maxResults;
|
2021-02-08 17:39:09 +01:00
|
|
|
const res = { newBytes: raw.newBytes, newTensors: raw.newTensors, peakBytes: raw.peakBytes, numKernelOps: raw.kernels.length, timeKernelOps: time, slowestKernelOps: slowest, largestKernelOps: largest };
|
|
|
|
data[name] = res;
|
2020-12-08 15:00:44 +01:00
|
|
|
log('Human profiler', name, res);
|
2020-11-01 19:07:53 +01:00
|
|
|
}
|