moment.js parse vs d3.time.parse
JavaScript performance comparison
Preparation code
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.0.1/d3.v3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/1.7.2/moment.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var ds1 = '2010-02-03T11:24:14',
ds2 = '2010-02-03',
d3DateTimeParser = d3.time.format.utc('%Y-%m-%dT%X').parse,
d3DateParser = d3.time.format.utc('%Y-%m-%d').parse;
function parseMoment(ds) {
return moment.utc(ds).toDate();
}
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Moment, datetime |
|
pending… |
D3, datetime |
|
pending… |
Moment, date |
|
pending… |
D3, date |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments