@abaplint/runtime 2.5.55 → 2.5.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,10 +84,11 @@ export declare class Statements {
84
84
  split: typeof split;
85
85
  translate: typeof translate;
86
86
  private readonly context;
87
+ private traceTotals;
87
88
  constructor(context: Context);
88
89
  private _trace;
89
90
  private _traceAsync;
90
- _setTrace(min?: number): void;
91
+ _setTrace(min?: number, totals?: boolean): void;
91
92
  deleteDatabase(table: string | ICharacter, options: IDeleteDatabaseOptions): Promise<void>;
92
93
  insertDatabase(table: string | ICharacter, options: IInsertDatabaseOptions): Promise<number | undefined>;
93
94
  message(options: IMessageOptions): Promise<void>;
@@ -86,33 +86,52 @@ class Statements {
86
86
  this.sort = sort_1.sort;
87
87
  this.split = split_1.split;
88
88
  this.translate = translate_1.translate;
89
+ this.traceTotals = {};
89
90
  this.context = context;
90
91
  }
91
- _trace(func, name, min) {
92
+ _trace(func, name, min, totals) {
92
93
  const exec = (...options) => {
93
94
  const start = Date.now();
94
95
  const result = func.bind(this)(...options);
95
96
  const runtime = Date.now() - start;
97
+ if (totals === true) {
98
+ if (this.traceTotals[name] === undefined) {
99
+ this.traceTotals[name] = 0;
100
+ }
101
+ this.traceTotals[name] += runtime;
102
+ }
96
103
  if (runtime >= min) {
97
104
  console.log(`STATEMENT: ${name}, ${runtime} ms`);
105
+ if (totals === true) {
106
+ console.log(JSON.stringify(this.traceTotals));
107
+ }
98
108
  }
99
109
  return result;
100
110
  };
101
111
  return exec;
102
112
  }
103
- _traceAsync(func, name, min) {
113
+ _traceAsync(func, name, min, totals) {
104
114
  const exec = async (...options) => {
105
115
  const start = Date.now();
106
116
  const result = await func.bind(this)(...options);
107
117
  const runtime = Date.now() - start;
118
+ if (totals === true) {
119
+ if (this.traceTotals[name] === undefined) {
120
+ this.traceTotals[name] = 0;
121
+ }
122
+ this.traceTotals[name] += runtime;
123
+ }
108
124
  if (runtime >= min) {
109
125
  console.log(`STATEMENT: ${name}, ${runtime} ms`);
126
+ if (totals === true) {
127
+ console.log(JSON.stringify(this.traceTotals));
128
+ }
110
129
  }
111
130
  return result;
112
131
  };
113
132
  return exec;
114
133
  }
115
- _setTrace(min = 10) {
134
+ _setTrace(min = 10, totals = false) {
116
135
  const candidates = [...Object.keys(this), ...Object.getOwnPropertyNames(Statements.prototype)];
117
136
  for (const c of candidates) {
118
137
  if (c === "context" || c === "constructor" || c.startsWith("_") || c === "loop") {
@@ -120,10 +139,10 @@ class Statements {
120
139
  }
121
140
  const func = this[c];
122
141
  if ((0, types_1.isAsyncFunction)(func)) {
123
- this[c] = this._traceAsync(func, c, min);
142
+ this[c] = this._traceAsync(func, c, min, totals);
124
143
  }
125
144
  else {
126
- this[c] = this._trace(func, c, min);
145
+ this[c] = this._trace(func, c, min, totals);
127
146
  }
128
147
  }
129
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.5.55",
3
+ "version": "2.5.56",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",