When does the pulsein() function start counting?
According the official Arduino Reference: PulseIn

Fragment:


  Reads a pulse (either HIGH or LOW) on a pin. For example, if value is
  HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then
  waits for the pin to go LOW and stops timing. Returns the length of
  the pulse in microseconds. Gives up and returns 0 if no pulse starts
  within a specified time out.