Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
// parse-profiler
//
// this script is used to parse performance profiling result.
// usage:
// STEP.1 - profiling
// > npm test -- model test/test-data/{path-to-my-model} --backend={cpu/webgl/wasm} --profile > profile.raw.log
// STEP.2 - parse
// > node script/parse-profiler < profile.raw.log > profile.parsed.log
 
import * as readline from 'readline';
const lines = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false });
 
// eslint-disable-next-line no-control-regex
const matcher = /Profiler\.([^[\s\x1b]+)(\x1b\[0m)? (\d.+Z)\|([\d.]+)ms on event '([^']+)' at (\d*\.*\d*)/;
 
const allEvents: any[] = [];
lines.on('line', (input) => {
  const matches = matcher.exec(input);
  if (matches) {
    // console.log(matches);
    const category = matches[1];
    const logTimeStamp = new Date(matches[3]);
    const ms = Number.parseFloat(matches[4]);
    const event = matches[5];
    const endTimeInNumber = matches[6];
    allEvents.push({ event, ms, logTimeStamp, category, endTimeInNumber });
  }
});
 
lines.on('close', () => {
  for (const i of allEvents) {
    console.log(
      `${(i.category + '           ').substring(0, 12)} ${(i.ms + '           ').substring(0, 12)} ${(
        i.event + '                                      '
      ).substring(0, 40)} ${i.endTimeInNumber}`,
    );
  }
});