Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
import { env } from './env-impl.js';
 
/**
 * @ignore
 */
export const TRACE = (deviceType: string, label: string) => {
  if (typeof env.trace === 'undefined' ? !env.wasm.trace : !env.trace) {
    return;
  }
  // eslint-disable-next-line no-console
  console.timeStamp(`${deviceType}::ORT::${label}`);
};
 
const TRACE_FUNC = (msg: string, extraMsg?: string) => {
  const stack = new Error().stack?.split(/\r\n|\r|\n/g) || [];
  let hasTraceFunc = false;
  for (let i = 0; i < stack.length; i++) {
    if (hasTraceFunc && !stack[i].includes('TRACE_FUNC')) {
      let label = `FUNC_${msg}::${stack[i].trim().split(' ')[1]}`;
      if (extraMsg) {
        label += `::${extraMsg}`;
      }
      TRACE('CPU', label);
      return;
    }
    if (stack[i].includes('TRACE_FUNC')) {
      hasTraceFunc = true;
    }
  }
};
 
/**
 * @ignore
 */
export const TRACE_FUNC_BEGIN = (extraMsg?: string) => {
  if (typeof env.trace === 'undefined' ? !env.wasm.trace : !env.trace) {
    return;
  }
  TRACE_FUNC('BEGIN', extraMsg);
};
 
/**
 * @ignore
 */
export const TRACE_FUNC_END = (extraMsg?: string) => {
  if (typeof env.trace === 'undefined' ? !env.wasm.trace : !env.trace) {
    return;
  }
  TRACE_FUNC('END', extraMsg);
};
 
/**
 * @ignore
 */
export const TRACE_EVENT_BEGIN = (extraMsg?: string) => {
  if (typeof env.trace === 'undefined' ? !env.wasm.trace : !env.trace) {
    return;
  }
  // eslint-disable-next-line no-console
  console.time(`ORT::${extraMsg}`);
};
 
/**
 * @ignore
 */
export const TRACE_EVENT_END = (extraMsg?: string) => {
  if (typeof env.trace === 'undefined' ? !env.wasm.trace : !env.trace) {
    return;
  }
  // eslint-disable-next-line no-console
  console.timeEnd(`ORT::${extraMsg}`);
};