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 Luxon vs Naked Benchmark created on December 21, 2023 Description Using Luxon to do date calculations > 52 weeks may be expensive. lets find out how expensive
Preparation HTML <script src ="https://cdn.jsdelivr.net/npm/luxon@3.4.4/build/global/luxon.min.js" > </script >
<div id ="thing" > </div >
Setup const MS_IN_SECOND = 1000 ;
const MS_IN_MINUTE = MS_IN_SECOND * 60 ;
const MS_IN_HOUR = MS_IN_MINUTE * 60 ;
const MS_IN_DAY = MS_IN_HOUR * 24 ;
const MS_IN_WEEK = MS_IN_DAY * 7 ;
const future = luxon.DateTime .local (2025 , 1 , 1 );
const segments = ["years" , "months" , "weeks" , "days" , "hours" , "minutes" , "seconds" ];
Test runner Ready to run.
Run Quick Run Testing in Test Ops/sec Naked const now = Date .now ()
const remaining = Math .max (1735689600000 - now, 0 );
var weeks = Math .floor (remaining / MS_IN_WEEK );
var days = Math .floor ((remaining % MS_IN_WEEK ) / MS_IN_DAY );
var hours = Math .floor ((remaining % MS_IN_DAY ) / MS_IN_HOUR );
var minutes = Math .floor ((remaining % MS_IN_HOUR ) / MS_IN_MINUTE );
var seconds = Math .ceil ((remaining % MS_IN_MINUTE ) / MS_IN_SECOND );
thing.innerText = `Weeks ${weeks} Days ${days} Hours ${hours} Minutes ${minutes} Seconds ${seconds} ` ;
ready
Luxon const now = luxon.DateTime .now ();
const diff = luxon.Interval .fromDateTimes (now, future);
const duration = diff.toDuration (segments);
const years = duration.get ('years' );
const months = duration.get ('months' );
const weeks = duration.get ('weeks' );
const days = duration.get ('days' );
const hours = duration.get ('hours' );
const minutes = duration.get ('minutes' );
const seconds = duration.get ('seconds' );
thing.innerText = `Years ${years} Months ${months} Weeks ${weeks} Days ${days} Hours ${hours} Seconds ${Math .ceil(seconds)} ` ;
ready