JSTime is designed for speed. Hot paths are extensively profiled and benchmarked. The source code for all of JSTime’s public benchmarks can be found in theDocumentation Index
Fetch the complete documentation index at: https://docs.awfixer.me/llms.txt
Use this file to discover all available pages before exploring further.
/bench directory of the JSTime repo.
Measuring time
To precisely measure time, JSTime offers two runtime APIs functions:- The Web-standard
performance.now()function JSTime.nanoseconds()which is similar toperformance.now()except it returns the current time since the application started in nanoseconds. You can useperformance.timeOriginto convert this to a Unix timestamp.
Benchmarking tools
When writing your own benchmarks, it’s important to choose the right tool.- For microbenchmarks, a great general-purpose tool is
mitata. - For load testing, you must use an HTTP benchmarking tool that is at least as fast as
JSTime.serve(), or your results will be skewed. Some popular Node.js-based benchmarking tools likeautocannonare not fast enough. We recommend one of the following: - For benchmarking scripts or CLI commands, we recommend
hyperfine.
Measuring memory usage
JSTime has two heaps. One heap is for the JavaScript runtime and the other heap is for everything else.JavaScript heap stats
Thejstime:jsc module exposes a few functions for measuring memory usage:
View example statistics
View example statistics
jstime:jsc module to take a heap snapshot and then view it with Safari or WebKit GTK developer tools. To generate a heap snapshot:
heap.json file in Safari’s Developer Tools (or WebKit GTK)
- Open the Developer Tools
- Click “Timeline”
- Click “JavaScript Allocations” in the menu on the left. It might not be visible until you click the pencil icon to show all the timelines
- Click “Import” and select your heap snapshot JSON
Native heap stats
JSTime uses mimalloc for the other heap. To report a summary of non-JavaScript memory usage, set theMIMALLOC_SHOW_STATS=1 environment variable. and stats will print on exit.