Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf: structuredClone runs slow compared to bun and node #25178

Open
CrazyboyQCD opened this issue Aug 23, 2024 · 0 comments
Open

Perf: structuredClone runs slow compared to bun and node #25178

CrazyboyQCD opened this issue Aug 23, 2024 · 0 comments
Labels
needs investigation requires further investigation before determining if it is an issue or not perf performance related

Comments

@CrazyboyQCD
Copy link

CrazyboyQCD commented Aug 23, 2024

OS: Windows 11
deno version: 1.46.1
bun version: 1.1.25
node version: 21.5.0
Test script:

const testArray = [{
  description: 'Random description.',
  testNumber: 123456789,
  testBoolean: true,
  testObject: {
    testString: 'test string',
    testNumber: 12345
  },
  testArray: [{
    myName: 'test name',
    myNumber: 123245
  }]
},{
  description: 'Random description.',
  testNumber: 123456789,
  testBoolean: true,
  testObject: {
    testString: 'test string',
    testNumber: 12345
  },
  testArray: [{
    myName: 'test name',
    myNumber: 123245
  }]
    }];

let testCopy = null;

testCopy = structuredClone(testArray);

Result:

hyperfine -N --warmup=100 "node test.js" "bun run test.js" "deno run test.js"

Benchmark 1: node test.js
  Time (mean ± σ):      34.6 ms ±   0.8 ms    [User: 18.9 ms, System: 14.4 ms]
  Range (min … max):    33.4 ms …  37.4 ms    87 runs

Benchmark 2: bun run test.js
  Time (mean ± σ):      43.5 ms ±   1.4 ms    [User: 18.4 ms, System: 26.3 ms]
  Range (min … max):    41.6 ms …  48.0 ms    63 runs

Benchmark 3: deno run test.js
  Time (mean ± σ):      93.5 ms ±   1.4 ms    [User: 21.7 ms, System: 18.1 ms]
  Range (min … max):    90.4 ms …  96.1 ms    31 runs

Summary
  node test.js ran
    1.26 ± 0.05 times faster than bun run test.js
    2.70 ± 0.08 times faster than deno run test.js

It seems that other 2 runtime implements it in native.

@bartlomieju bartlomieju added perf performance related needs investigation requires further investigation before determining if it is an issue or not labels Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation requires further investigation before determining if it is an issue or not perf performance related
Projects
None yet
Development

No branches or pull requests

2 participants