Mostly I want to benchmark code in our production monorepo, so a web tool doesn’t make much sense. We have a bunch of data structure code and standard utility libraries so it’s not feasible to copy everything into a web form.
When doing data structure work I’ve started writing micro benchmark files with mitata (https://github.com/evanwashere/mitata) which does a decent job running GC between runs and outputs some very cute graphs and such. I recently rewrote a core container class we use at Notion and for a 5% speed up on a bunch of our public API routes.
OP, I see you have a mitata-inspired benchmark library “benchmate” (https://github.com/3rd/benchmate/tree/master), I’m curious about difference from mitata, what was missing from it, features added? I looked a bit at the code and it’s certainly easier to read… mitata codebase feels like C written by someone who’s too smart.
Hey, yes it draws a lot of inspiration from mitata, but it's much tinier and with less features. I remember I was getting some less accurate measurements in browsers when I tried it (~2 years ago) and I decided to build my own and got the results I expected.
Mitata has added a ton of things since then and it's very mature, and it's built by evan so it's definitely the right choice over benchmate. I used benchmate because I can easily extend it to support the upcoming features in BenchJS.
BenchJS is for easily building shareable benchmarks, and I want to evolve it into a nice code analysis tool. It uses Babel and esbuild to transform and bundle the code before it gets evaluated, and I want to use this to extract more useful insights like the number of operations of a given type (ex. array methods), code path analysis (coverage-like), inline indicators of how much % time a line took, etc.
Thank you for sharing the mitata tool! I was looking for something like that(for my monorepo).
I was wondering if there is a tool that can profile nodejs code? I did find some options(most of them are web tools) but they dont seem to give out information as much as mitata about what and where my code is used more often although mitata is a benchmarking tool.
Start node with `node --inspect-brk …` or send SIGUSR1 to a running node process to expose the debug protocol port.
Then, connect with Chrome developer tools. You should see a NodeJS icon in the devtools if there’s a node process on your machine listening on the devtools port. You can use SSH port forwarding or similar to connect to processes on other machines like in a production environment.
Use the Chrome developer tools to take a profile, save it to disk, then analyze it using https://profiler.firefox.com
In production we use Datadog to collect and inspect profiles.
Mostly I want to benchmark code in our production monorepo, so a web tool doesn’t make much sense. We have a bunch of data structure code and standard utility libraries so it’s not feasible to copy everything into a web form.
When doing data structure work I’ve started writing micro benchmark files with mitata (https://github.com/evanwashere/mitata) which does a decent job running GC between runs and outputs some very cute graphs and such. I recently rewrote a core container class we use at Notion and for a 5% speed up on a bunch of our public API routes.
OP, I see you have a mitata-inspired benchmark library “benchmate” (https://github.com/3rd/benchmate/tree/master), I’m curious about difference from mitata, what was missing from it, features added? I looked a bit at the code and it’s certainly easier to read… mitata codebase feels like C written by someone who’s too smart.
Hey, yes it draws a lot of inspiration from mitata, but it's much tinier and with less features. I remember I was getting some less accurate measurements in browsers when I tried it (~2 years ago) and I decided to build my own and got the results I expected.
Mitata has added a ton of things since then and it's very mature, and it's built by evan so it's definitely the right choice over benchmate. I used benchmate because I can easily extend it to support the upcoming features in BenchJS.
BenchJS is for easily building shareable benchmarks, and I want to evolve it into a nice code analysis tool. It uses Babel and esbuild to transform and bundle the code before it gets evaluated, and I want to use this to extract more useful insights like the number of operations of a given type (ex. array methods), code path analysis (coverage-like), inline indicators of how much % time a line took, etc.
Thank you for sharing the mitata tool! I was looking for something like that(for my monorepo).
I was wondering if there is a tool that can profile nodejs code? I did find some options(most of them are web tools) but they dont seem to give out information as much as mitata about what and where my code is used more often although mitata is a benchmarking tool.
What profilers do you use? Thanks :)
Start node with `node --inspect-brk …` or send SIGUSR1 to a running node process to expose the debug protocol port.
Then, connect with Chrome developer tools. You should see a NodeJS icon in the devtools if there’s a node process on your machine listening on the devtools port. You can use SSH port forwarding or similar to connect to processes on other machines like in a production environment.
Use the Chrome developer tools to take a profile, save it to disk, then analyze it using https://profiler.firefox.com
In production we use Datadog to collect and inspect profiles.
Clinic.js was promising but it's not maintained anymore, would be great if we had a modern alternative: https://clinicjs.org/