oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.38k stars 2.78k forks source link

Computing performance is 4 times slower than nodejs #10261

Open FishOrBear opened 7 months ago

FishOrBear commented 7 months ago

What version of Bun is running?

1.1.3

What platform is your computer?

Microsoft Windows NT 10.0.19044.0 x64 (win10)

What steps can reproduce the bug?

const COUNT1 = 1024;
const COUNT2 = 10240;
const COUNT3 = 102400;

function encrypt(buf, value = 199)
{
    let count = Math.min(buf.length, COUNT1);
    for (let i = 0; i < count; i++)
        buf[i] += value;

    count = Math.min(buf.length, COUNT2);
    for (let i = COUNT1; i < count; i += 2)
        buf[i] += value;

    count = Math.min(buf.length, COUNT3);
    for (let i = COUNT2; i < count; i += 4)
        buf[i] += value;
}

const buf = Buffer.alloc(100000);
function aa()
{
    console.time("j");
    for (let i = 0; i < 100000; i++)
        encrypt(buf, 199);
    console.timeEnd("j");
}

for (let index = 0; index < 10; index++) {
    aa()
}

What is the expected behavior?

nodejs:2.044s bunjs : 8.01s

What do you see instead?

No response

Additional information

No response

Pismice commented 5 months ago

Tried running the same on Ubuntu 22.04.4, I have the same time (~2.5s) for both. (bun version 1.1.3). Did you try running it multiple times ? Maybe you were just unlucky.