strange behavior in time measurement.

Try disabling interrupts before you calculate dif and enable them afterwards.