@abaplint/runtime 2.5.55 → 2.5.57

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 readonly 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>;
@@ -87,32 +87,53 @@ class Statements {
87
87
  this.split = split_1.split;
88
88
  this.translate = translate_1.translate;
89
89
  this.context = context;
90
+ this.traceTotals = {};
90
91
  }
91
- _trace(func, name, min) {
92
+ _trace(func, name, min, totals) {
93
+ const tt = this.traceTotals;
92
94
  const exec = (...options) => {
93
95
  const start = Date.now();
94
96
  const result = func.bind(this)(...options);
95
97
  const runtime = Date.now() - start;
98
+ if (totals === true) {
99
+ if (tt[name] === undefined) {
100
+ tt[name] = 0;
101
+ }
102
+ tt[name] += runtime;
103
+ }
96
104
  if (runtime >= min) {
97
105
  console.log(`STATEMENT: ${name}, ${runtime} ms`);
106
+ if (totals === true) {
107
+ console.log(JSON.stringify(tt));
108
+ }
98
109
  }
99
110
  return result;
100
111
  };
101
112
  return exec;
102
113
  }
103
- _traceAsync(func, name, min) {
114
+ _traceAsync(func, name, min, totals) {
115
+ const tt = this.traceTotals;
104
116
  const exec = async (...options) => {
105
117
  const start = Date.now();
106
118
  const result = await func.bind(this)(...options);
107
119
  const runtime = Date.now() - start;
120
+ if (totals === true) {
121
+ if (tt[name] === undefined) {
122
+ tt[name] = 0;
123
+ }
124
+ tt[name] += runtime;
125
+ }
108
126
  if (runtime >= min) {
109
127
  console.log(`STATEMENT: ${name}, ${runtime} ms`);
128
+ if (totals === true) {
129
+ console.log(JSON.stringify(tt));
130
+ }
110
131
  }
111
132
  return result;
112
133
  };
113
134
  return exec;
114
135
  }
115
- _setTrace(min = 10) {
136
+ _setTrace(min = 10, totals = false) {
116
137
  const candidates = [...Object.keys(this), ...Object.getOwnPropertyNames(Statements.prototype)];
117
138
  for (const c of candidates) {
118
139
  if (c === "context" || c === "constructor" || c.startsWith("_") || c === "loop") {
@@ -120,10 +141,10 @@ class Statements {
120
141
  }
121
142
  const func = this[c];
122
143
  if ((0, types_1.isAsyncFunction)(func)) {
123
- this[c] = this._traceAsync(func, c, min);
144
+ this[c] = this._traceAsync(func, c, min, totals);
124
145
  }
125
146
  else {
126
- this[c] = this._trace(func, c, min);
147
+ this[c] = this._trace(func, c, min, totals);
127
148
  }
128
149
  }
129
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.5.55",
3
+ "version": "2.5.57",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",