index.js
This file
Path
bench/index.js
63 lines · 1.3 KiB · JavaScript
Last changed by
feat: add `clsx/lite` moduleLuke Edwardsbefore adoption1a49142
History of this fileTake it
chore: add node benchmarksLuke Edwardsbefore adoptionb7c3973
lines 1–5why, one step back1const { Suite } = require('benchmark');2const classnames = require('classnames');3const classcat = require('classcat');4const clsx = require('../dist/clsx');5const old = require('clsx');feat: add `clsx/lite` moduleLuke Edwardsbefore adoption1a49142
line 6why, one step back6const lite = require('../dist/lite');chore: add node benchmarksLuke Edwardsbefore adoptionb7c3973
lines 7–10why, one step back78function bench(name, ...args) {9 console.log(`\n# ${name}`);10 new Suite()chore(bench): include ≠ symbolLuke Edwardsbefore adoption855eec2
line 11why, one step back11 .add('classcat ≠ ', () => classcat.apply(classcat, [args]))chore: add node benchmarksLuke Edwardsbefore adoptionb7c3973
lines 12–14why, one step back12 .add('classnames ', () => classnames.apply(classnames, args))13 .add('clsx (prev) ', () => old.apply(old, args))14 .add('clsx ', () => clsx.apply(clsx, args))feat: add `clsx/lite` moduleLuke Edwardsbefore adoption1a49142
line 15why, one step back15 .add('clsx (lite) ', () => lite.apply(lite, args))chore: add node benchmarksLuke Edwardsbefore adoptionb7c3973
lines 16–63why, one step back16 .on('cycle', e => console.log(' ' + e.target))17 .run();18}1920bench(21 'Strings',22 'foo', '', 'bar', 'baz', 'bax', 'bux'23);2425bench(26 'Objects',27 { foo:true, bar:true, bax:true, bux:false },28 { baz:true, bax:false, bux:true }29);3031bench(32 'Arrays',33 ['foo', 'bar'],34 ['baz', 'bax', 'bux']35);3637bench(38 'Nested Arrays',39 ['foo', ['bar']],40 ['baz', ['bax', ['bux']]]41);4243bench(44 'Nested Arrays w/ Objects',45 ['foo', { bar:true, bax:true, bux:false }],46 ['bax', { bax:false, bux:true }]47);4849bench(50 'Mixed',51 'foo', 'bar',52 { bax:true, bux:false },53 ['baz', { bax:false, bux:true }]54);5556bench(57 'Mixed (Bad Data)',58 'foo', 'bar',59 undefined, null, NaN,60 () => {},61 { bax:true, bux:false, 123:true },62 ['baz', { bax:false, bux:true, abc:null }, {}]63);