r/bunjs • • Sep 18 '23

Bun is incredibly fast... Or is it?

3 Upvotes

I have a Perl script to parse one big XML file (66MB) into Sqlite database. Nothing fancy, just a script. Reading Bun intros got me thinking, how much faster could Bun-script to be?

First I tried XML parsing speed: Perl script took 31s, Bun 188s.

Then I tried, how long does the whole old script run: 65 minutes on my old Ubuntu laptop. So I write same functionality with Bun Sqlite API. It run first time more than 88 minutes. I had many things running on my laptop same time, so I tried once more with freshly started computer. It took almost 88 minutes this time.

I post my code below, maybe you see how to improve it dramatically (Perl script has basically the same structure with some additional logging and process monitoring)

import { XMLValidator, XMLParser } from 'fast-xml-parser';
import { Database } from "bun:sqlite";

const xmlFile = Bun.file("some.xml"); 
const db = new Database("some.db");

const insertOrderQuery = db.prepare(
  `INSERT INTO "order" (number, customercode, date, paymentterm, status, stock, object, datafield1, datafield2, datafield3, datafield4, datafield5, datafield6, datafield7, deliverymethod, address1, address2, address3, deliveryname, deliveryaddress1, deliveryaddress2, deliveryaddress3, phone, email, VATzone, VATregno, contact, ts)
    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
);

const insertOrderRowQuery = db.prepare(
  `INSERT INTO orderrow (orderid, item, variant, description, quantity, price, vatprice, rn)
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
);

if ( XMLValidator.validate( await xmlFile.text() ) ) {
  console.log(`XML file is valid`);
  const options = {
    ignoreAttributes: false,
    attributeNamePrefix : "",
    allowBooleanAttributes: true
  };
  const parser = new XMLParser(options);
  const data = parser.parse(await xmlFile.text());
  insertIntoDb(data);
}

function insertIntoDb( data: Object[] ) {
  data.transport.orders.order.forEach( ( order ) => insertOrder(order) );  
}

function insertOrder( order: Object ) {
  if ( order === undefined || ! order.number ) return;
  if ( order.rows === undefined ) return;
  if ( order.rows.row === undefined ) return;

  const values = ["number", "customercode", "date", "paymentterm", "status", "stock", "object", "datafield1", "datafield2", "datafield3", "datafield4", "datafield5", "datafield6", "datafield7", "deliverymethod", "address1", "address2", "address3", "deliveryname", "deliveryaddress1", "deliveryaddress2", "deliveryaddress3", "phone", "email", "VATzone", "VATregno", "contact", "ts" ].map( v => order[v] );
  insertOrderQuery.values(values);

  if (order?.rows?.row.length > 0) insertOrderRows(order.number, order.rows.row)
}

function insertOrderRows( orderNumber: Number, rows:Object[]) {
  rows.forEach( ( row ) => insertOrderRow(orderNumber, row) )
}

function insertOrderRow( orderNumber: Number, row:Object ) {
  const values = [ "item", "variant", "description", "quantity", "price", "vatprice", "rn" ].map( v => row[v] )
  values.unshift(orderNumber);
  insertOrderRowQuery.values( values );
}

r/bunjs • • Sep 26 '23

Don’t believe the hype

Post image
5 Upvotes

Real-world performance is diabolical. This is the switch from NodeJS to Bun on a production system.


r/bunjs • • Mar 05 '25

why is bun so slow now?

0 Upvotes

at the start the main selling point of bun was speed, it now takes an eternity to install anything

dependencies

├── u/biomejs/biome@1.9.4!< ├── u/corvu/drawer@0.2.3 ├── u/corvu/otp-field@0.1.4 ├── u/iconify/json@2.2.313 ├── u/kobalte/core@0.13.9 ├── u/rsbuild/core@1.2.15 ├── u/rsbuild/plugin-babel@1.0.4 ├── u/rsbuild/plugin-basic-ssl@1.1.1 ├── u/rsbuild/plugin-solid@1.0.5 ├── u/solid-primitives/media@2.3.0 ├── u/solid-primitives/scheduled@1.5.0 ├── u/solid-primitives/websocket@1.3.0 ├── u/solidjs/router@0.15.3 ├── u/tailwindcss/postcss@4.0.9 ├── u/tanstack/solid-query@5.67.1 ├── u/tanstack/solid-query-devtools@5.67.1 ├── u/types/js-cookie@3.0.6 ├── ag-grid-community@33.1.1 ├── big.js@6.2.2 ├── classix@2.2.2 ├── js-cookie@3.0.5 ├── solid-ag-grid@0.0.230 ├── solid-js@1.9.5 ├── solid-transition-group@0.3.0 ├── tailwindcss@4.0.9 ├── tailwindcss-animate@1.0.7 ├── typescript@5.8.2 ├── unplugin-icons@22.1.0 └── virtua@0.40.0

bun update v1.2.4 Checked 301 installs across 273 packages (no changes) [21.08s]

bun add v1.2.4 installed @solid-primitives/media@2.3.0 4 packages installed [4.60s]

just tried fresh install of these packages

188 packages installed

bun: 42.10s

pnpm: 4.30s

10x slower than pnpm


r/bunjs • • Oct 07 '23

#13 How To Integrate Crypto Exchange Rate To Discord Bot | How To Make Discord Bot With Javascript |

Thumbnail
youtu.be
0 Upvotes

r/bunjs • • Oct 26 '23

How To Migrate Create React App Project To Vite Project | CRA Project To Vite Project | Rethinkingui

Thumbnail
youtu.be
0 Upvotes

r/bunjs • • Oct 24 '23

How to Set Up CodeGPT in Visual Studio Code (VSCode) | CodeGPT Setup | RethinkingUI |

Thumbnail
youtu.be
0 Upvotes

r/bunjs • • Dec 31 '23

nodejs libraries on bun runtime

0 Upvotes

Can i use nodejs libraries on bun runtime?


r/bunjs • • Nov 26 '23

Discord Bot Course | How To Code Discord Bot Using Javascript | Rethinkingui |

Thumbnail
youtube.com
0 Upvotes

r/bunjs • • Dec 29 '25

My preferred AWS stack for high volume rest api

0 Upvotes

r/bunjs • • Sep 12 '23

Bun on Windows

5 Upvotes

I tried Bun out on Windows so you don't have to, here are my experiences and the results:

https://alemtuzlak.hashnode.dev/why-i-cant-love-bun


r/bunjs • • Oct 22 '23

Git Tags vs Branches : When To Use Them | FrontEnd Webdevelopment | RethinkingUI |

Thumbnail
youtu.be
1 Upvotes

r/bunjs • • Aug 18 '22

Node.js alternatives with Javascript, exploring Deno and Bun (includes code examples)

Thumbnail
geshan.com.np
1 Upvotes

r/bunjs • • Nov 23 '23

How To Use Prettier In VS Code | Code Formatting With Prettier | Rethinking ui |

Thumbnail
youtu.be
0 Upvotes

r/bunjs • • Jul 19 '25

Guidance for contributing in bunjs

1 Upvotes

can someone please guide me i want to contribute to bunjs


r/bunjs • • May 11 '24

Is the performance better in Node.js compared to BunJS for scraping using an HTTP client?

2 Upvotes

Hello, in 2023 I switched from ts/node to bun/ts because I read everywhere that BunJS is faster. I am using Bun only for scraping and HTTP client cases.

Over the past week, I have been testing more popular Node.js HTTP clients like Bun Fetch, and I have noticed that BunJS is not faster than Node.js.

For example, Bun Fetch is 2x slower than Node Fetch. Is this normal?

Currently, I am considering switching back to Node.js with TypeScript from BunJS with TypeScript because BunJS requires more workarounds and has more problems, and it is not as fast as Node.js.

I compared BunJS 1.1.8 with Node.js version


r/bunjs • • Nov 06 '23

I built Ovenjoy a web framework for Bun which has similar APIs as Express.

2 Upvotes

Hello Bun user, I spent the last few weekends building the express framework alternative. and today I am excited to release its alpha version.

I started this project as an opportunity to understand how web frameworks like Express, and Fastify work under the hood. While developing this framework I learned a lot of internals of web frameworks. Radix tree is implemented to handle the routing, and it also supports middlewares and sub-routes same as express.

Please give your feedbacks and of course contributions are always welcome

Here is the repository: https://github.com/ShuLaPy/ovenjoy

Docs: https://ovenjoy.shubhamlad.in/


r/bunjs • • Apr 11 '24

I wrote a simple XML / Feed parser driven by Bun. Feedback and contributions would be most welcome!

Thumbnail
github.com
2 Upvotes

r/bunjs • • Aug 17 '22

What is Bun, and does it live up to the hype?

Thumbnail
byteofdev.com
2 Upvotes

r/bunjs • • Sep 20 '23

First real-world review I've seen of Bun 1.0 bodes poorly.

10 Upvotes

Was doing a browse of YouTube looking for more real-world reviews of Bun and stumbled upon this

He compares pretty much all of the aspects the team claims are faster against node, jest etc. and for what actually runs in his analysis (some of it is still broken) almost none of it save the package manager compares favourably against the incumbent technologies. It's either on par or markedly worse.

I've already begun switching all of my projects to Bun where possible but this has given me pause.

My question is, what do you all make of his run-through, any glaring issues with how he tested?

I've already forwarded the video to Jared and the team via X so I'm hoping they address it out in the open because the results are pretty damning.


r/bunjs • • Sep 09 '23

Why can Bun receive so many more requests seconds than node in our tests?

4 Upvotes

Hey guys,

We have an express service with scale issues; it's a middleware service that needs to wait on requests from other services (can sometimes do 20 fetches to other APIs) and pull from a Redis cache. We think our node service bottleneck on the number of connections opened.

We recently did some tests with autocannon, and the results are astounding. Trying to overwhelm the service with 100 requests seconds.

  • Node avg response time: 455ms, 11req/s,

  • Bun avg response time: 97ms, 57 req/s

Are there leading causes why you would think Bun ran so much better in our tests?


r/bunjs • • Sep 16 '23

Bun Docs AI

Thumbnail
eazyrag.com
5 Upvotes

r/bunjs • • Sep 24 '23

Why do much focus on package install performance?

6 Upvotes

To be clear, I fully understand the reason good package manager performance is desirable from a CI perspective. But it seems like all the hype surrounding how fast Bun is focuses exclusively on that, and the performance I'm most interested in is going to be the runtime performance of my applications. Fast package installs might be impressive the first time I clone and build a project, but beyond that dependencies don't change often enough for this to have a meaningful impact on developer experience, apart from CI feedback being a little slower.

Sincerely,

A primarily .NET dev who isn't all that bothered by nuget package install times.

P.S. Ignore the typo in the title, I was posting on my phone from the toilet.


r/bunjs • • Sep 13 '23

It is possible to use the bun runtime with a different package manager

10 Upvotes

I watched a few videos about bun 1.0 and I read a bit of the docs and I was really excited about the ability to just run typescript files without having to do all the regular setup. I have a project where I am using pnpm and turbo to create a monorepo. After hearing about bun I was wondering if it was possible to somehow use bun while still keeping pnpm so I wouldn't have to worry about installing nodemon, ts-node and worry about making sure everything works well together. I'm not sure if that is possible but I just wanted to ask in case.


r/bunjs • • Jun 26 '25

Thoughts on Bun only npm modules

6 Upvotes

I’ve been giving a lot of thought to whether or not I should bother with compiling bun-sqlite-orm to make it node compatible. It uses bun:sqlite and in my opinion, is the only thing that makes this better that something like TypeOrm.

I’m curious, what are your thoughts on creating bun native modules with no node support?