Skip to content

Commit

Permalink
bench
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean O'Bannon committed Sep 23, 2022
0 parents commit f9fff41
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.history
.DS_Store
node_modules
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .yarn/install-state.gz
Binary file not shown.
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
19 changes: 19 additions & 0 deletions bench.js
Original file line number Diff line number Diff line change
@@ -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()
11 changes: 11 additions & 0 deletions fastParseZone.js
Original file line number Diff line number Diff line change
@@ -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) {

}
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -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");
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "benchmark",
"version": "1.0.0",
"type": "module",
"dependencies": {
"benchmark": "^2.1.4",
"moment": "^2.29.4"
}
}
46 changes: 46 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f9fff41

Please sign in to comment.