In current main board firmware, the endstops are polled in function CheckEndstops which is in class DDA. So you could put a call to debugPrintf in there.
A 20ms pulse will be long enough provided that the step rate is at least 1 step per 20ms, so 50 steps/sec, which should always be the case when homing. For example, 10mm/sec @ 80 steps/mm would be 800 steps/sec.
Expansion board firmware uses interrupt-driven endstop inputs. Future main board firmware will too.