Replies: 4 comments 7 replies
-
Hi @ironydips Please provide us the code sample of the console command you're using to run with bun and node |
Beta Was this translation helpful? Give feedback.
-
@Jarred-Sumner I understand you are busy with new releases, but pls help me understand performance difference as i have already moved my entire backend to bun and literally see no difference in performance when comparing side by side to node, rather cpu utilisation has went up a little on bun. My site www.stockmock.in is used by more than 50k users on daily basis and our business involves cpu intensive and high memory tasks. I am very very serious on using this on production but the query like above is stopping me to go deeper on this. Simple Example like: sort() is 5x slower on bun than nodejs. Am i missing something here? pls guide. If you can just help me understand these 2 queries: one mentioned at top of this thread, and other this .sort() --> this will bre great starting point for me to dig deeper.
Node Sort: 123ms I am using bun version: 1.0.0 System Config: MacBook Pro: Apple M1, memory 8 GB, HD 250 GB, (MacOS Big Sur) |
Beta Was this translation helpful? Give feedback.
-
My PC specs: |
Beta Was this translation helpful? Give feedback.
-
As this is CPU-intensive task you're just comparing V8 engine (nodejs) vs JavaScriptCore engine (bun). I've installed v8 and javascriptcore from jsvu and run slightly modified script and get following results (on my machine):
scriptfunction multiplyMatrices(m1, m2) {
const result = new Array(m1.length).fill().map(() => new Array(m2[0].length).fill(0));
for (let i = 0; i < m1.length; i++) {
for (let k = 0; k < m1[0].length; k++) {
for (let j = 0; j < m2[0].length; j++) {
result[i][j] += m1[i][k] * m2[k][j];
}
}
}
return result;
}
// Create larger matrices to test performance
const C = Array.from({length: 300}, () => Array.from({length: 300}, () => Math.floor(Math.random() * 100)));
const D = Array.from({length: 300}, () => Array.from({length: 300}, () => Math.floor(Math.random() * 100)));
// repeat 50 times
for (let i = 0; i < 50; i++) {
let _ = multiplyMatrices(C, D);
} So, essentially V8 is more optimized for this CPU-intensive task. |
Beta Was this translation helpful? Give feedback.
-
New to Bun. Looking fore faster alternate to nodejs for cpu intensive tasks.
When running below code in nodejs, it is 2 times faster than Bun. Please help me understand why? as Bun is expected to perform better.
Node Perfomace: 120ms
Bun Performance: 225ms
Beta Was this translation helpful? Give feedback.
All reactions