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.

A faster way to convert a timestamp ➜ Hour, Min, Sec
A faster way to convert a timestamp ➜ Hour, Min, Sec
  • Ben Joffe
  • www.benjoffe.com
50% faster than usual, by breaking the dependency chain.
Interesting but the math is so complicated for understanding and future maintenance of code.
Thank you for sharing.