Frequency counter with variable gate time