Estimo was created with idea in mind how to measure parse/compile/execution time for javascript libs.
It uses puppeteer to generate Chrome Timelines. Which can be transformed in human-readable format by Tracium.
Keep in mind there result depends on your device and available resources.
Inspired by Size Limit. Thanks @ai for support.
JavaScript is the most expensive part of our frontend.
We should really care about size. But in additional to size, we also need to think about how long our JavaScript will process.
3.5 seconds to process 170 KB of JS and 0.1 second for 170 KB of JPEG. Addy Osmani
npm i estimoor
yarn add estimoconst estimo = require('estimo')
const path = require('path')
;(async () => {
const report = await estimo(
path.resolve(path.join(__dirname, '..', 'libs', 'someLib.js'))
)
console.log(report)
})()estimo -l ./libs/someLib.js[
{
"library": "someLib.js",
"parseHTML": 1.62,
"styleLayout": 54.98,
"paintCompositeRender": 1.1,
"scriptParseCompile": 1.16,
"scriptEvaluation": 8.66,
"javaScript": 9.82,
"garbageCollection": 0,
"other": 15.83,
"total": 83.35
}
]You can also pass few files and they will process in one Chrome instance.
estimo -l ./libs/someLib.js ./libs/myLib.jsconst report = await estimo([
'/path/to/libs/someLib.js',
'/path/to/libs/myLib.js',
])All metrics in milliseconds.
We measure system-cpu time. The number of seconds that the process has spent on the CPU.
We not including time spent waiting for its turn on the CPU.
-
library - Library name.
-
parseHTML - Time which was spent for
ParseHTML,ParseAuthorStyleSheetevents. -
styleLayout - Time which was spent for
ScheduleStyleRecalculation,UpdateLayoutTree,InvalidateLayout,Layoutevents. -
paintCompositeRender - Time which was spent for
Animation,HitTest,PaintSetup,Paint,PaintImage,RasterTask,ScrollLayer,UpdateLayer,UpdateLayerTree,CompositeLayersevents. -
scriptParseCompile - Time which was spent for
v8.compile,v8.compileModule,v8.parseOnBackgroundevents. -
scriptEvaluation - Time which was spent for
EventDispatch,EvaluateScript,v8.evaluateModule,FunctionCall,TimerFire,FireIdleCallback,FireAnimationFrame,RunMicrotasks,V8.Executeevents. -
javaScript - Time which was spent for both event groups (scriptParseCompile and scriptEvaluation).
-
garbageCollection - Time which was spent for
MinorGC,MajorGC,BlinkGC.AtomicPhase,ThreadState::performIdleLazySweep,ThreadState::completeSweep,BlinkGCMarkingevents. -
other - Time which was spent for
MessageLoop::RunTask,TaskQueueManager::ProcessTaskFromWorkQueue,ThreadControllerImpl::DoWorkevents. -
total - Total time.
The CPU Throttling Rate Emulation Options allow you to generate a Performance timeline under specified CPU conditions. To turn on CPU emulation, you must pass the emulateCpuThrottling flag along with additional configuration options.
-
emulateCpuThrottling (optional;
false) - This flag allows the other CPU Throttling Rate Options to be respected. They will be completely ignored unless this flag is set. -
cpuThrottlingRate (optional;
1) - Sets the CPU throttling rate. The number represents the slowdown factor (e.g., 2 is a "2x" slowdown).
JS API:
...
await estimo('/absolute/path/to/lib', {
emulateCpuThrottling: true,
cpuThrottlingRate: 4,
})
...CLI:
estimo -l ./libs/someLib.js --cpu --cpuRate 4The Network Emulation Options allow you to generate a Performance timeline under specified network conditions. To turn on network emulation, you must pass the emulateNetworkConditions flag along with additional configuration options.
-
emulateNetworkConditions (optional;
false) - This flag allows the other Network Emulation Options to be respected. They will be completely ignored unless this flag is set. -
offline (optional;
false) - Passing theofflineflag to the generate command emulate a network disconnect. -
latency (optional;
0) - Artificial, minimum latency between request sent and response header received expressed in milliseconds (ms). -
downloadThroughput (optional:
0) - The maximum download speed in megabits per second.0disables throttling. -
uploadThroughput (optional:
0) - The maximum upload speed in megabits per second.0disables throttling. -
connectionType (optional:
none) - A label of the supposed underlying network connection type that the browser is using. Supported values are documented under Chrome Headless' ConnectType documentation. Variants:none,cellular2g,cellular3g,cellular4g,bluetooth,ethernet,wifi,wimax,other.
JS API:
...
await estimo('/absolute/path/to/lib', {
emulateNetworkConditions: true,
offline: false,
latency: 150,
downloadThroughput: 1.6,
uploadThroughput: 0.75,
connectionType: 'cellular3g',
})
...CLI:
estimo -l ./libs/someLib.js --net --latency 150 --download 1.6 --upload 0.75 --connection cellular3gFeel free to ask or open an issue.
MIT
