diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a5de95c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.history +.DS_Store +node_modules diff --git a/.yarn/cache/benchmark-npm-2.1.4-3d024a205e-aa466561d4.zip b/.yarn/cache/benchmark-npm-2.1.4-3d024a205e-aa466561d4.zip new file mode 100644 index 0000000..2f6ed01 Binary files /dev/null and b/.yarn/cache/benchmark-npm-2.1.4-3d024a205e-aa466561d4.zip differ diff --git a/.yarn/cache/lodash-npm-4.17.21-6382451519-eb835a2e51.zip b/.yarn/cache/lodash-npm-4.17.21-6382451519-eb835a2e51.zip new file mode 100644 index 0000000..22ac44c Binary files /dev/null and b/.yarn/cache/lodash-npm-4.17.21-6382451519-eb835a2e51.zip differ diff --git a/.yarn/cache/moment-npm-2.29.4-902943305d-0ec3f9c2bc.zip b/.yarn/cache/moment-npm-2.29.4-902943305d-0ec3f9c2bc.zip new file mode 100644 index 0000000..78acd14 Binary files /dev/null and b/.yarn/cache/moment-npm-2.29.4-902943305d-0ec3f9c2bc.zip differ diff --git a/.yarn/cache/platform-npm-1.3.6-8c3cef9352-6f472a09c6.zip b/.yarn/cache/platform-npm-1.3.6-8c3cef9352-6f472a09c6.zip new file mode 100644 index 0000000..978ae74 Binary files /dev/null and b/.yarn/cache/platform-npm-1.3.6-8c3cef9352-6f472a09c6.zip differ diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz new file mode 100644 index 0000000..840fbc5 Binary files /dev/null and b/.yarn/install-state.gz differ diff --git a/.yarnrc.yml b/.yarnrc.yml new file mode 100644 index 0000000..3186f3f --- /dev/null +++ b/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/bench.js b/bench.js new file mode 100644 index 0000000..2eba05c --- /dev/null +++ b/bench.js @@ -0,0 +1,19 @@ +import benchmark from 'benchmark' + +import moment from 'moment' + +const { Suite } = benchmark; + +let suite = new Suite() + +const INPUT = '2022-09-12T18:11:04.884+05:00' + +suite + .add('moment#parseZone', () => moment.parseZone(INPUT)) + .on('cycle', function(event) { + console.log(String(event.target)) + }) + .on('complete', function() { + console.log('Fastest is ' + this.filter('fastest').map('name')) + }) + .run() \ No newline at end of file diff --git a/fastParseZone.js b/fastParseZone.js new file mode 100644 index 0000000..41e1cd9 --- /dev/null +++ b/fastParseZone.js @@ -0,0 +1,11 @@ +import moment from 'moment'; + +/** + * Parses an ISO-8601 formatted date in this format only: + * - "2022-12-03T12:30:00.000-07:00" + * + * Returns a Moment.JS object (moment) + */ +export function fastParseZone(input) { + +} diff --git a/index.js b/index.js new file mode 100644 index 0000000..ec1719d --- /dev/null +++ b/index.js @@ -0,0 +1,11 @@ +import moment from 'moment'; + +const INPUT = '2022-09-12T18:11:04.884+05:00' + +const now = Date.now(); +console.log("Starting benchmark"); +for (let i = 0; i < 100000; i++) { + moment.parseZone(INPUT) +} +const elapsed = Date.now() - now; +console.log("Finished benchmark in " + elapsed + "ms"); diff --git a/package.json b/package.json new file mode 100644 index 0000000..eaf0b6b --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "benchmark", + "version": "1.0.0", + "type": "module", + "dependencies": { + "benchmark": "^2.1.4", + "moment": "^2.29.4" + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..eeb21e4 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,46 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 5 + cacheKey: 8 + +"benchmark@npm:^2.1.4": + version: 2.1.4 + resolution: "benchmark@npm:2.1.4" + dependencies: + lodash: ^4.17.4 + platform: ^1.3.3 + checksum: aa466561d4f2b0a2419a3069b8f90fd35ffacf26849697eea9de525ecfbd10b44da11070cc51c88d772076db8cb2415641b493de7d6c024fdf8551019c6fcf1c + languageName: node + linkType: hard + +"benchmark@workspace:.": + version: 0.0.0-use.local + resolution: "benchmark@workspace:." + dependencies: + benchmark: ^2.1.4 + moment: ^2.29.4 + languageName: unknown + linkType: soft + +"lodash@npm:^4.17.4": + version: 4.17.21 + resolution: "lodash@npm:4.17.21" + checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7 + languageName: node + linkType: hard + +"moment@npm:^2.29.4": + version: 2.29.4 + resolution: "moment@npm:2.29.4" + checksum: 0ec3f9c2bcba38dc2451b1daed5daded747f17610b92427bebe1d08d48d8b7bdd8d9197500b072d14e326dd0ccf3e326b9e3d07c5895d3d49e39b6803b76e80e + languageName: node + linkType: hard + +"platform@npm:^1.3.3": + version: 1.3.6 + resolution: "platform@npm:1.3.6" + checksum: 6f472a09c61d418c7e26c1c16d0bdc029549d512dbec6526216a1e59ec68100d07007d0097dcba69dddad883d6f2a83361b4bdfe0094a3d9a2af24158643d85e + languageName: node + linkType: hard