All pages

Speed test

The popover’s Network view after a speed test, under Today, Week and Month and the four figures: a dial with the download speed in its centre, the download and upload speeds, the network, how much the test used and when, then ping, jitter, and ping while downloading and while uploading; Back and Test Again buttons.

Click Test Speed in the popover's Network view, choose Test Internet Speed from the right-click menu, or click Test Now on the Network page of the main window. It tests the connection you're on. NetworkMonitor runs networkQuality, the speed test Apple ships with every Mac since Monterey, against Apple's nearest servers.

What you get

Where it shows

Choose Card or Compact in Network's settings, behind the gear on the Network page.

Data use

A test uses real data, typically 50–500 MB, more on a very fast line. So:

How it's built

The engine is /usr/bin/networkQuality. If a Mac doesn't have it, the speed test is left out of the popover, the Network page and the menu. Other engines were considered and turned down:

Option Why not
Ookla's CLI needs installing, and its licence doesn't allow bundling it with the app
M-Lab NDT publishes every tester's IP address and result as open data
Cloudflare's endpoints, or our own would mean owning a measurement engine worse than the one already on every Mac
fast.com no API

The run (SpeedTestRunner.swift) is networkQuality -s -v -c<file>:

It runs inside a pseudo-terminal, because through a pipe the tool prints nothing until the end. That's the same reason nettop runs in one; see architecture. The live line is redrawn about five times a second and parsed as it comes. A run that takes over 90 seconds is stopped.

Then a short ping-only pass (-d -u, under a second, no test data) adds eight more idle samples, because a single batch of idle pings on Wi-Fi varied from 49 to 74 ms between runs a minute apart.

The figures (SpeedTest.swift):

Fresh by construction. Each run is a new process in its own folder, $TMPDIR/NetworkMonitor-speedtest-<UUID>/, which is deleted as soon as the result is read, on success, failure, timeout or cancel. A result can only come from the run that just finished. Cancelling sends SIGTERM, then SIGKILL after 0.3 s. A folder left by a run the app was force-quit in the middle of is removed at the next launch, once it's over 10 minutes old, so a run in another process is never touched.

State (SpeedTestController.swift) goes idle → confirming (metered only) → running → finished or failed. The live readings are a separate observable object from the phase, so the app list isn't rebuilt five times a second.

Preferences: speedTestUnit (bits or bytes, default bytes; named for the speed test, which had the setting first, and kept so earlier choices carry over) and speedTestStyle (card or compact).

Tests (SpeedTestTests.swift) never spend data. The parser and decoder run against output captured from the real tool. The runner and controller run against a stand-in networkQuality script that prints the same kind of output, writes JSON, and can be told to fail, fail its ping pass or run slowly. Run the real thing sparingly while developing: each run costs real data.

This page is docs on GitHub, as of 365f4d4. To suggest a change, open an issue.