porffor 0.16.0-ab08df866 → 0.16.0-b099006b8

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.
package/runner/index.js CHANGED
@@ -64,7 +64,12 @@ if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(fi
64
64
  process.argv.splice(process.argv.indexOf(file), 1);
65
65
 
66
66
  if (file === 'profile') {
67
- await import('./profiler.js');
67
+ await import('./profile.js');
68
+ await new Promise(() => {}); // do nothing for the rest of this file
69
+ }
70
+
71
+ if (file === 'debug') {
72
+ await import('./debug.js');
68
73
  await new Promise(() => {}); // do nothing for the rest of this file
69
74
  }
70
75
 
@@ -76,11 +81,6 @@ if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(fi
76
81
  process.argv.push('--asur', '--wasm-debug');
77
82
  }
78
83
 
79
- if (file === 'debug') {
80
- await import('./debug.js');
81
- await new Promise(() => {}); // do nothing for the rest of this file
82
- }
83
-
84
84
  file = process.argv.slice(2).find(x => x[0] !== '-');
85
85
 
86
86
  const nonOptOutFile = process.argv.slice(process.argv.indexOf(file) + 1).find(x => x[0] !== '-');
@@ -89,6 +89,8 @@ if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(fi
89
89
  }
90
90
  }
91
91
 
92
+ globalThis.file = file;
93
+
92
94
  if (!file) {
93
95
  if (process.argv.includes('-v') || process.argv.includes('--version')) {
94
96
  // just print version
@@ -115,17 +117,20 @@ const print = str => {
115
117
  process.stdout.write(str);
116
118
  };
117
119
 
120
+ let runStart;
118
121
  try {
119
122
  if (process.argv.includes('-b')) {
120
123
  const { wasm, exports } = await compile(source, process.argv.includes('--module') ? [ 'module' ] : [], {}, print);
121
124
 
125
+ runStart = performance.now();
122
126
  if (!process.argv.includes('--no-run')) exports.main();
123
127
 
124
128
  console.log(`\n\nwasm size: ${wasm.byteLength} bytes`);
125
129
  } else {
126
130
  const { exports } = await compile(source, process.argv.includes('--module') ? [ 'module' ] : [], {}, print);
127
131
 
128
- if (!process.argv.includes('-no-run')) exports.main();
132
+ runStart = performance.now();
133
+ if (!process.argv.includes('--no-run')) exports.main();
129
134
  }
130
135
  // if (cache) process.stdout.write(cache);
131
136
  } catch (e) {
@@ -133,4 +138,4 @@ try {
133
138
  console.error(process.argv.includes('-i') ? e : `${e.constructor.name}: ${e.message}`);
134
139
  }
135
140
 
136
- if (process.argv.includes('-t')) console.log(`${process.argv.includes('-b') ? '' : '\n\n'}total time: ${(performance.now() - start).toFixed(2)}ms`);
141
+ if (process.argv.includes('-t')) console.log(`${process.argv.includes('-b') ? '' : '\n\n'}total time: ${(performance.now() - start).toFixed(2)}ms\nexecution time: ${(performance.now() - runStart).toFixed(2)}ms`);
File without changes