Get the time for the first rising edge, first falling edge, and second rising edge. Then calculate the cycle time tc from the rising edge times, the pulse duration tp to the falling edge, and then calculate tp/tc. You can use millis() or (better) micros() for getting the times.