A user tested the code below and found that it suffers from poor performance, being 100 times slower than Node.js. If you have time, please investigate it. Preliminary analysis suggests it's caused by object instantiation using new. Could there be some time-consuming operations during the new process? Generally, people don't write code this way, but in Node.js, this kind of usage takes a normal amount of time, whereas in PerryTS, it is not normal. If you can investigate and fix this, it would be great.
hello.ts
class MyClass {
private value: number;
constructor(value: number) {
this.value = value;
}
getValue() {
return this.value;
}
}
function main() {
const iterations = 100000000;
// 类实例化和调用
let start = performance.now();
let sum = 0;
for (let i = 0; i < iterations; i++) {
const obj = new MyClass(1);
sum += obj.getValue();
}
let end = performance.now();
let elapsed = end - start;
console.log(`${elapsed} ms, sum: ${sum}`);
// 纯计算测试
start = performance.now();
sum = 0;
for (let i = 0; i < iterations; i++) {
sum += 1;
}
end = performance.now();
elapsed = end - start;
console.log(`${elapsed} ms, sum: ${sum}`);
}
main();
Machine System: Windows 10
Nodejs:v24.15.0, result:
node hello.ts
153.82350000000002 ms, sum: 100000000
122.30950000000001 ms, sum: 100000000
PerryTS:v0.5.923, result:
.\hello.exe
16970.964111328125 ms, sum: 100000000
143.921142578125 ms, sum: 100000000
A net friend tested with cpp:

A user tested the code below and found that it suffers from poor performance, being 100 times slower than Node.js. If you have time, please investigate it. Preliminary analysis suggests it's caused by object instantiation using new. Could there be some time-consuming operations during the new process? Generally, people don't write code this way, but in Node.js, this kind of usage takes a normal amount of time, whereas in PerryTS, it is not normal. If you can investigate and fix this, it would be great.
hello.ts
Machine System: Windows 10
Nodejs:v24.15.0, result:
node hello.ts
153.82350000000002 ms, sum: 100000000
122.30950000000001 ms, sum: 100000000
PerryTS:v0.5.923, result:
.\hello.exe
16970.964111328125 ms, sum: 100000000
143.921142578125 ms, sum: 100000000
A net friend tested with cpp: