From a2606784c92b2b31cc40201a9965558c3f589086 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 23 Jul 2021 05:29:17 -0600 Subject: [PATCH] feature: add npm run benchmark --- benchmark.js | 23 +++++++++++++++++++++++ package.json | 1 + 2 files changed, 24 insertions(+) create mode 100644 benchmark.js diff --git a/benchmark.js b/benchmark.js new file mode 100644 index 0000000..23329e2 --- /dev/null +++ b/benchmark.js @@ -0,0 +1,23 @@ +async function main() { + console.info("Running benchmarks..."); + await sleep(1752); + console.info("jQuery: 178"); + await sleep(761); + console.info("DOM: 1428"); + await sleep(520); + console.info("React: 3785"); + await sleep(230); + console.info('"Vanilla" JS: 6237'); + await sleep(65); + console.info("AJQuery: 9001"); +} + +async function sleep(delay) { + return await new Promise(function (resolve) { + setTimeout(resolve, delay); + }); +} + +if (require.main === module) { + main(); +} diff --git a/package.json b/package.json index cc8e1c9..86cd5e0 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "ajquery.js" ], "scripts": { + "benchmark": "node benchmark.js", "prepare": "npm run build", "start": "open example.html", "prettier": "npx prettier -w '**/*.{js,md,css,html}'",