# Measuring editor latency

Typing latency is the time between pressing a key and seeing the result on screen.
It is one of the most direct measures of how responsive a text editor feels.

Unlike file-opening time or startup performance, typing latency affects every edit.
Small delays may be difficult to notice individually, but inconsistent response times can make an editor feel less predictable.

Measuring this requires more than timing how quickly an editor processes a keyboard event.
The measurement needs to include the time until the updated document is actually displayed.

## What is typing latency?

When a key is pressed, the input passes through several stages before the corresponding character appears on screen.

A simplified sequence is:

1. The operating system receives the keyboard event.
2. The editor processes the input.
3. The document is updated.
4. The editor prepares and renders the updated content.
5. The resulting frame is presented on screen.

The total time between the input event and the updated frame is the **keypress-to-frame latency**.

This differs from measuring only the duration of a keyboard event handler or text insertion operation.
An editor may update its internal document quickly while delaying the visual result until a later frame.

### Display refresh rate

A display operating at 60 Hz refreshes approximately every 16.7 ms.

This introduces a timing constraint: an edit must be processed before the next available presentation opportunity to appear in that frame.
If the editor misses that opportunity, the result may not appear until a subsequent refresh.

At 120 Hz, the refresh interval is approximately 8.3 ms.

Display refresh rate therefore affects measured keypress-to-frame latency, even when the editor's processing time remains unchanged.
For meaningful comparisons, editors should be tested under the same display conditions.

## Measuring keypress-to-frame latency

Our benchmarks use [Keypress.sh](https://keypress.sh), a tool for measuring the time between simulated keyboard input and the corresponding visual update.

The objective is to measure the complete input-to-display path rather than an individual operation inside the editor.
This allows different editors to be compared without relying on their internal performance instrumentation.

## Understanding latency measurements

A single latency number cannot describe the complete typing experience.
An editor may respond quickly to most inputs while occasionally producing much slower frames.

For this reason, our benchmarks report several statistics.

### Median

The median represents the middle measurement.
Half of the recorded keypresses have latency below the median, and half have latency above it.
It provides a useful indication of typical response time.

### P95 and P99

P95 is the latency at or below which 95% of measured keypresses fall.

P99 represents the corresponding threshold for 99% of measurements.

These percentiles help identify occasional delays that may not be visible in the median.
For example, an editor may have a median latency of 16 ms but a P95 of 80 ms.
Most edits appear quickly, but a meaningful proportion take considerably longer.

### Maximum latency

Maximum latency is the slowest recorded keypress in the test.
It can reveal isolated stalls, although it is more sensitive to individual outliers than percentile measurements.

### Tail spread

We also report the difference between P95 and the median:

```
Tail spread = P95 − median
```

A smaller tail spread indicates more consistent response times.
Two editors can have similar median latency but substantially different tail spreads.
The editor with the smaller spread will generally produce fewer slow responses within the measured distribution.

## Why editor latency varies

Typing latency is not necessarily constant.
It can change depending on the document, editing operation, editor configuration, and background activity.
Common sources of additional work include:

- Syntax highlighting and parsing
- Autocomplete and diagnostics
- Document indexing
- Minimap and scrollbar updates
- Multiple views of the same document
- Plugins and extensions
- Layout and rendering

Some of this work may happen synchronously during an edit.
Other operations may run asynchronously but still compete for processing time or affect frame presentation.

### Document size

Large documents can expose performance characteristics that are difficult to observe in small files.

An operation that is inexpensive in a document containing a few hundred lines may become costly when the document contains hundreds of thousands or millions of lines.

**Our benchmarks therefore include source files of different sizes, as well as generated files containing up to 20 million lines.**

### Multiple views

Displaying the same document in multiple editor panes can introduce additional rendering or document-management work.

**We test both single-pane and dual-pane configurations to measure whether opening another view affects typing latency.**

### Editor configuration

Editor features and configuration can affect the results.
Extensions, completion systems, syntax highlighting, and other background operations may introduce additional work.
Benchmark results should therefore be interpreted in the context of the documented editor configuration.

## Limitations of latency measurements

Keypress-to-frame measurements provide a useful indication of editor responsiveness, but they are not a complete description of the user experience.

### Display timing

Measurements depend on display refresh rate and the timing of input relative to frame presentation.
An editor that completes an edit just before a refresh may produce a different result from one that completes the same work just after it.

### Simulated input

Automated keyboard input improves repeatability but does not reproduce every characteristic of physical keyboard input.

The measurements are intended to compare editor responsiveness under controlled conditions, not to represent the complete hardware-to-photon latency experienced by a person typing on a physical keyboard.

### Background activity

Operating-system scheduling, background processes, and editor-specific tasks can introduce variation between runs.
A benchmark represents performance under the tested conditions rather than a guaranteed latency for every system or workload.

### Statistical interpretation

Percentiles are calculated from a finite sample.
With 200 keypresses, P95 describes the upper portion of the observed distribution, while P99 and maximum latency are more sensitive to individual measurements.
Results should be interpreted alongside the test conditions and other reported statistics.

## Reproducing the benchmarks

The benchmark tool and test files are available publicly.

- [Keypress.sh](https://keypress.sh), our benchmark tool
- [Test files](https://github.com/peeknext/keypress/tree/main/test_files), source files used in the benchmarks
- [Raw measurements](https://github.com/peeknext/keypress/tree/main/scripts/benchmarks), raw test data
- [Benchmark results](/benchmarks/), measurements, editor versions, and test conditions

Reproducibility is important because editor performance depends on hardware, operating-system behavior, configuration, and workload.
Publishing the methodology and test files allows results to be independently examined and compared.

## Results

Using this methodology, Peeknext measured 16.6 ms P95 keypress-to-frame latency while editing a 753,821-line C source file on a 60 Hz display.

The complete benchmark includes comparisons with other macOS editors, single-pane and dual-pane configurations, large-file tests, and memory measurements.

[View the complete benchmarks →](/benchmarks/)

