First day of week

JavaScript performance comparison

Test case created by Santeri Hiltunen

Preparation code

<script src="https://unpkg.com/moment"></script>
<script src="https://unpkg.com/js-joda"></script>

      
<script>
Benchmark.prototype.setup = function() {
  "use strict";
  
  var dateStr = "2017-03-15";
  var TemporalAdjusters = JSJoda.TemporalAdjusters;
  var DayOfWeek = JSJoda.DayOfWeek;
  var LocalDate = JSJoda.LocalDate;
  var firstDayOfWeek = TemporalAdjusters. previousOrSame(DayOfWeek.MONDAY);
  

};
</script>

Preparation code output

<script src="https://unpkg.com/js-joda"></script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Moment naive
moment(dateStr).startOf("isoWeek").format();
pending…
js-joda
var firstDayOfWeek = TemporalAdjusters. previousOrSame(DayOfWeek.MONDAY);
LocalDate.parse(dateStr).with(firstDayOfWeek).toString();
pending…
js-joda lifted
LocalDate.parse(dateStr).with(firstDayOfWeek).toString();
pending…
Moment
moment(dateStr, "YYYY-MM-DD").startOf("isoWeek").format("YYYY-MM-DD");
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments