Libraries: High-Performance Time Functions (TimeUtils) - page 4

 
amrali #:

The "DayOfWeekBenchmark.mq5" script is attched below.

int DayOfWeek_JoffeNarrow(const datetime t)
{
   uint days = (uint)((ulong)t / DAYSECS);

   ulong product = (ulong)days * (ulong)JOFFE_NARROW_M;

   uint low = (uint)product;

   uint r = low + (uint)JOFFE_NARROW_Z;

   return (int)(r >> 29);
}

Best?

 
fxsaber #:

Best?

Yes.

speedup=   1.561x

I would adopt it if it gives > 5-10x speed-up.