11const Benchmark = require ( 'benchmark' ) ;
22const nextRandomDate = require ( '../next-random-date' ) ;
3+ const names = require ( '../names' ) ;
34const tsDate = require ( '../../dist/locale/en/index' ) ;
5+ const tsDatePrev = require ( 'ts-date' ) ;
46const moment = require ( 'moment' ) ;
57const dateFns = require ( 'date-fns' ) ;
68
@@ -20,16 +22,19 @@ onCycle();
2022
2123const suite = new Benchmark . Suite ( 'Difference in hours between two dates' ) ;
2224suite
23- . add ( ' moment' , function ( ) {
25+ . add ( names . moment , function ( ) {
2426 return moment ( d1 ) . diff ( d2 , 'hours' )
2527 } , { onCycle} )
26- . add ( 'moment cached' , function ( ) {
28+ . add ( names . momentCached , function ( ) {
2729 return d1Moment . diff ( d2 , 'hours' )
2830 } , { onCycle} )
29- . add ( 'date-fns' , function ( ) {
31+ . add ( names . dateFns , function ( ) {
3032 return dateFns . differenceInHours ( d1 , d2 )
3133 } , { onCycle} )
32- . add ( 'ts-date' , function ( ) {
34+ . add ( names . tsDatePrev , function ( ) {
35+ return tsDatePrev . diffHours ( d1 , d2 )
36+ } , { onCycle} )
37+ . add ( names . tsDate , function ( ) {
3338 return tsDate . diffHours ( d1 , d2 )
3439 } , { onCycle} )
3540;
0 commit comments