jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
Date.prototype.getStartOfDay = function() {
this.setHours(0, 0, 0, 0)
return this
}
Date.prototype.getStartOfWeek = function() {
if (this.getDay()) {
this.setHours(-Math.abs(this.getDay() - 1) * 24, 0, 0, 0)
} else {
this.setHours(-6 * 24, 0, 0, 0)
}
return this
}
Date.prototype.getStartOfMonth = function() {
if (this.getDate()) {
this.setHours(-Math.abs(this.getDate() - 1) * 24, 0, 0, 0)
} else {
this.setHours(0, 0, 0, 0)
}
return this
}
Date.prototype.getStartOfYear = function() {
if (this.getDayOfYear()) {
this.setHours(-Math.abs(this.getDayOfYear() - 1) * 24, 0, 0, 0)
} else {
this.setHours(0, 0, 0, 0)
}
return this
}
Date.prototype.getDayOfYear = function() {
var date = this.clone(this)
date.setMonth(0, 0)
return Math.round((this - date) / 8.64e7)
}
Date.prototype.clone = function() {
return new Date(this.getTime())
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Moment.js Library |
| ready |
Native Date |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.