-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Description
I was comparing it with other alternatives like esprima and espree.
From what I found, esprima & espree have lot of features but have smaller Unpacked size as reported by npm.
It is relatively faster, but considering the small scope of it's features, I don't think that performance gain is beneficial. (Like if we have to run small expressions, then every library does it within 20ms and 10-20ms is not big gain).
For reference,
| criteria | jsep | esprima | espree |
|---|---|---|---|
| Unpacked size | 388kB | 314kB | 76.4kB |
| Features | minimal | complete JS | complete JS |
| benchmark time | 274 | 491 | 417 |
benchmark code
import jsep from 'jsep';
import * as espree from 'espree';
import * as esprima from 'esprima';
import {Bench} from 'tinybench';
const script = '2+'.repeat(1000) + '1';
const bench = new Bench({time: 100});
bench
.add('jsep', () => {jsep(script)})
.add('esprima', () => {esprima.parseScript(script)})
.add('espree', () => {espree.parse(script)})
;
bench.run().then(t => console.table(t.map(tt => ({name: tt.name, avg: tt.result.mean*1000, var: tt.result.variance*1000})))).catch(e => console.error(e))
/* Console
┌─────────┬───────────┬────────────────────┬────────────────────┐
│ (index) │ name │ avg │ var │
├─────────┼───────────┼────────────────────┼────────────────────┤
│ 0 │ 'jsep' │ 274.0221922120003 │ 49.0996204188163 │
│ 1 │ 'esprima' │ 491.28853894916233 │ 286.50706192948815 │
│ 2 │ 'espree' │ 417.70407563696307 │ 304.5463155112307 │
└─────────┴───────────┴────────────────────┴────────────────────┘
*/After this, I became curious to know what is the selling point of jsep and why/when should one prefer it over others ?
Metadata
Metadata
Assignees
Labels
No labels