How Does a Click Speed Test Work? Timing, Bias and Noise in a Tiny Instrument

Image

 A click speed test looks like the simplest instrument you could build. Count the clicks, divide by the time, show the number. A first-year student could write one in an afternoon. Yet it raises most of the questions that come up in real measurement systems: how coarse is the result, is it biased, where does timing noise come from, and how do you tell a genuine signal from a generated one?

That makes it a good small project for a programming or instrumentation course. This article takes one apart. If you'd like something to compare your own version with, here's a working CPS test with run lengths from 1 to 60 seconds.

The basic model

CPS means clicks per second. The usual design starts the clock on the first click, so there's no countdown and no reaction time in the result. Every click until time T is counted, and the score is N divided by T.

let t0 = null, count = 0;
const T = 10; // seconds

function onClick() {
  const now = performance.now();
  if (t0 === null) t0 = now;
  if ((now - t0) / 1000 >= T) return;
  count++;
}

const score = () => count / T;

About ten lines, and already two interesting errors.

Error 1: quantization

N is a whole number, so the score can only move in steps of 1/T. That's the resolution of the instrument.

Run length TResolutionAs a share of a 7 CPS result
1 s1.0 CPS14.3%
5 s0.2 CPS2.9%
10 s0.1 CPS1.4%
30 s0.033 CPS0.5%
60 s0.017 CPS0.2%

Displaying 10.0 after a one-second run suggests a precision that isn't there. The decimal is always zero, because it can't be anything else.

Error 2: the fencepost

The second error is easier to miss. The first click happens at t = 0 and is counted, so a steady clicker is measured from a click, not from the middle of a gap.

Take someone clicking at exactly 9.5 CPS, with a gap of about 105 ms. In one second the clicks land at 0, 105, 211 and so on up to 947 ms. That's 10 clicks, so the test reports 10.0. In general the count is r times T rounded up to the next whole number, where r is the true rate.

A one-second click speed test result of 10.0 clicks per second, 10 clicks, with a human rhythm check A one-second run: 10 clicks, shown as 10.0 per second. A perfectly steady clicker anywhere from just above 9 to 10 per second would get the same score.

Rounding up adds half a click on average. So the expected bias is +0.5/T: about +0.5 CPS on a one-second run, but only +0.05 CPS over ten seconds. This is the classic fencepost problem. Ten posts make only nine gaps.

A less biased estimator uses the gaps directly. Divide the number of intervals by the time between the first and last click:

const rate = (times.length - 1) / (times[times.length - 1] - times[0]) * 1000;

It's a good exercise to ask why almost no public test does this. The answer is usability: players expect the count on screen divided by the time on screen to match the score. A slightly biased number that everyone can check by hand is often the better product decision.

Where timing noise comes from

A click passes through several stages before your code sees it, and each one adds its own delay.

  • Switch bounce and debounce. Metal contacts chatter for a few milliseconds when they close. The mouse ignores repeat signals for a short window. A 20 ms window, for example, sets a hard ceiling of 50 clicks per second.
  • USB polling. A device polled at 125 Hz reports every 8 ms. At 1,000 Hz it's every 1 ms.
  • Event loop. JavaScript handlers run one at a time, so a busy page delays them. The event's own timestamp is usually a better record than the moment the handler runs.
  • Clock resolution. Browsers deliberately coarsen high-resolution timers for security reasons.

How much does it matter? Suppose each click is off by up to 8 ms. For a single 100 ms gap, the error at each end can reach 8%. Over a ten-second run, most of it cancels, because the end of one gap is the start of the next. Only the two ends of the run are left, and 8 ms out of 10,000 is 0.08%. Jitter ruins individual gaps and hardly touches the average, so the same hardware can be fine for measuring speed and poor for measuring rhythm.

Human or script? A one-line classifier

Many tests also guess whether the clicks came from a person. The simplest useful feature is the coefficient of variation (CV) of the gaps: the standard deviation divided by the mean. It has no units, so it works at any speed.

SourceExample gaps (ms)MeanStandard deviationCV
Uneven, finger-like140, 165, 150, 180, 15515813.60.086
Scripted100, 100, 101, 99, 1001000.60.006

Those are illustrative numbers, but they show the idea: the two sources differ by more than a factor of ten, so a threshold in between separates them. Any fixed threshold has limits, though. A script can add random delays and a very steady person can look mechanical. Treat the result as a hint, never as proof. Students can go further with the shape of the gap distribution, the correlation between neighbouring gaps, or a small trained model.

Designing a fair experiment

Suppose you want to know whether a new mouse really makes you faster. The measurement lessons above turn into a protocol:

  1. Fix the run length. Ten seconds keeps the resolution at 0.1 CPS and the bias near 0.05. Scores from different lengths can't be compared directly.
  2. Alternate the devices. Use A, B, B, A instead of all A and then all B, so tiredness is shared between both.
  3. Repeat. Take at least five runs per device and report the median with the spread.
  4. Compare the gain with the noise. If your own runs vary by 0.4 CPS, a 0.2 CPS improvement hasn't been shown.

For context, regular one-finger clicking over ten seconds usually falls between 5 and 7. This breakdown of average clicks per second shows how the figure shifts with run length and technique.

Try it as a mini project

  • Implement both estimators, N/T and intervals over time, and feed them simulated clicks at a known rate. Plot the bias against T.
  • Add uniform jitter of 8 ms and check which statistic suffers more, the mean rate or the CV.
  • Collect 20 runs from classmates and 20 from a simple script, choose a CV threshold, and report false positives and false negatives.
  • Write one paragraph on what your classifier gets wrong and why.

What the small instrument teaches

The code for a click counter fits on a postcard, but a trustworthy number needs more than code. You have to know the resolution, look for bias, understand which errors cancel and which don't, and say clearly what the result can't tell you. Those habits carry over unchanged to sensors, benchmarks and lab work.

Image
Previous Post Next Post