← Back to the homepage

Backprop Bulletin practical guide

Run a small language model locally and measure its speed and memory use

Illustration: a terminal window prints a model's answer one word at a time, beside a stopwatch that times the first word and the pace, and a memory gauge filled up to a dashed peak line.

Before you build on a model that runs on your own computer, you need three numbers: how long it takes to start answering, how fast it writes, and how much memory it holds. This guide gives you a small meter that measures all three for any model program. You check the meter first against a simulated model whose behaviour is known, then use it on a real open-weight model with llama.cpp.

By Backprop Bulletin.Comment on this guide Tested on 18 November 2026 with Node.js 24.22.1 and 22.23.5 on Linux.

What you will build

The meter is one file, measure-model.mjs. You give it the command that runs a model, and it starts that program, watches it and reports:

It works in two ways. In output mode, it measures any program that prints generated text. In server mode, it starts a model server such as llama.cpp's llama-server, waits until the model is loaded, sends one request and times the answer as it streams back. Server mode separates loading time from answering time, and it uses the server's own count of tokens, the units a model generates.

The same file contains a simulated model: a few lines of code with a fixed loading time, a fixed pace and a fixed amount of memory. It is not a language model. It exists so that you can see the meter read a target whose true values you know before you trust the meter with a real model.

Prerequisites and tested runtime

Create an empty folder, open a terminal in it and download the meter into it:

Download measure-model.mjs JavaScript, 398 lines, 19.7 kB

Before running a downloaded file, read it. You can also check that you have the same file this guide was tested with:

Run

sha256sum measure-model.mjs

Expected output

289c52216765fc8682d2aeaafc29550b32c4ed45ead288351166fca5b1726852  measure-model.mjs

How the meter measures

Time

The meter notes the time on Node.js's high-resolution clock just before it starts the program, and again each time output arrives:

  child.stdout.on("data", (chunk) => {
    const t = performance.now();
    first ??= t;
    last = t;
    reads += 1;

Time to first output is the first of those times minus the start. The rate is the number of words after the first, divided by the time from the first output to the last. In output mode the meter counts words, because it cannot know how a program splits text into tokens. If the whole output arrives in fewer than five reads, or within a tenth of a second, the meter does not report a rate at all, because there is nothing to time:

    if (reads < 5 || span < 100) {

Memory

Linux publishes each process's memory use in /proc/<pid>/status. The meter reads it every 0.1 s while the program runs:

function readStatus(pid) {
  let text;
  try { text = readFileSync(`/proc/${pid}/status`, "utf8"); } catch { return null; }
  const kb = (field) => Number(new RegExp(`^${field}:\\s+(\\d+) kB`, "m").exec(text)?.[1]);
  const s = { rss: kb("VmRSS"), hwm: kb("VmHWM"), anon: kb("RssAnon"), file: kb("RssFile") };
  return Number.isFinite(s.rss) ? s : null; // a process that has just exited has no memory lines left
}

Three of those fields appear in the report. VmRSS is the resident set size: the memory the process holds in RAM right now. VmHWM is its peak, the "high water mark", which the kernel keeps itself, so a brief peak between two of the meter's readings is not lost. RssFile is the part of the resident memory that maps files. A model file that a program maps into memory, rather than reading into memory it allocated itself, is counted there.

The meter also looks for processes that the measured program started, using the parent process number that Linux records for every process. Their memory is not counted, and the report says so:

      if (stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1] === String(pid)) found.push(Number(name));

Server mode

With --server, the meter picks a free port, puts it where your command has {port}, starts the server and asks GET /health every 20 ms. llama.cpp documents that this answers 503 while the model is loading and 200 when the server is ready:

      if ((await call(port, "GET", "/health")).status === 200) readyAt = performance.now();

Then it sends one chat completion with streaming turned on, in the OpenAI-compatible form that llama-server accepts, and asks for the token count at the end of the stream:

      model: "local", messages: [{ role: "user", content: opts.prompt }], max_tokens: opts.maxTokens, temperature: 0, stream: true, stream_options: { include_usage: true },

If the server reports a count, the rate uses it; if not, the meter counts the pieces of text that arrived instead, and says so:

    const tokens = Number.isInteger(reported?.completion_tokens) ? reported.completion_tokens : pieces;

When the answer is complete, the meter stops the server with SIGTERM.

Rounding

The report rounds times to 0.1 s, rates to whole numbers and memory to 0.1 GB, and shows anything smaller as "under 0.1 GB". One run on a busy computer varies by more than finer figures would suggest. Add --precise to see milliseconds, megabytes and two decimal places.

Check the meter on a simulated model

The simulated model's behaviour is set by one line:

const SIM = { loadMs: 1250, everyMs: 100, firstTokenMs: 250, megabytes: 250, words: 49 };

It "loads" for 1.25 s, during which it fills a 250 MB block of memory, standing in for model weights. Writing to every byte makes the memory really resident, not just reserved:

  return Buffer.allocUnsafe(SIM.megabytes * 1e6).fill(0x5a);

Then it prints one word every 0.1 s, 49 words in all. In server mode it answers /health with 503 until 1.25 s have passed, and streams its first token 0.25 s after each request. When the meter starts it, the meter passes its start time in the MEASURE_MODEL_STARTED environment variable, so the simulated schedule counts from that moment, including Node.js's own start-up. Other programs ignore the variable.

First, see what the simulated model prints. Twelve words take about 2.4 s:

Run

node measure-model.mjs simulate --words 12

Expected output (simulated model)

This text comes from the simulated model in measure-model.mjs. It is not

Now measure it in output mode. Everything after -- is the command being measured:

Run

node measure-model.mjs measure -- node measure-model.mjs simulate

Expected output (simulated model)

measured: node measure-model.mjs simulate
exit status: 0
time to first output: 1.3 s (includes start-up and loading)
output: 49 words; output begins: "This text comes from the simulated model in ..."
output rate: 10 words per second
peak memory: 0.3 GB (VmHWM)
of which file-backed: under 0.1 GB (RssFile, at the highest sample)

Every figure matches what the simulated model is known to do. The first word came 1.25 s after the start, plus the few milliseconds it takes to pass text through a pipe, which rounds to 1.3 s. The pace is 10 words per second. The peak of about 0.3 GB is the 250 MB block plus the memory Node.js itself uses, and the small file-backed part is the Node.js program and its libraries, mapped from disk. If your computer is busy, a time can come out 0.1 s higher; the automated check that reruns this page allows each command three attempts for that reason.

Now the same simulated model as a server:

Run

node measure-model.mjs measure --server -- node measure-model.mjs simulate --serve {port}

Expected output (simulated model)

measured: node measure-model.mjs simulate --serve {port}
server ready after: 1.3 s (start-up and loading)
memory when ready: 0.3 GB (VmRSS)
time to first token: 0.3 s (from sending the request)
generated: 49 tokens, as counted by the server; text begins: "This text comes from the simulated model in ..."
generation rate: 10 tokens per second
the server's own figure: 10 tokens per second (timings.predicted_per_second)
peak memory: 0.3 GB (VmHWM)
of which file-backed: under 0.1 GB (RssFile, at the highest sample)

Loading (1.3 s) and answering (0.3 s to the first token) are now separate figures. The last rate line is the server's own measurement, which llama-server sends in a timings object; the simulated server imitates it. Two independent readings that agree are a good sign that neither is distorted.

With a real model

These steps use llama.cpp and Qwen3.5-0.8B, a small open-weight model published under the Apache 2.0 licence, in the file Qwen3.5-0.8B-Q4_0.gguf (563 MB). Backprop Bulletin did not run these steps for this guide: no real model was downloaded or measured. The file names, sizes and SHA-256 values below are the ones GitHub and Hugging Face list for these files, copied on 18 November 2026. The commands are for Linux on a 64-bit Intel or AMD processor; if uname -m prints aarch64, use the ubuntu-arm64 archive from the same release page and check its own SHA-256 there.

  1. Download llama.cpp. The notes of llama.cpp release v1.0.0, published on 13 November 2026, point to build b12359 for its programs. This archive is the Linux build that runs on the processor alone:
    curl -LO https://github.com/ggml-org/llama.cpp/releases/download/b12359/llama-b12359-bin-ubuntu-x64.tar.gz
  2. Check it against the SHA-256 that GitHub lists beside the file on the release page. The command should print llama-b12359-bin-ubuntu-x64.tar.gz: OK; if it prints anything else, delete the file and do not run it:
    echo "0bc1f091e8916102b6d8f2cf944233a620e90a0f856c72d0ce41150c65c2e72e  llama-b12359-bin-ubuntu-x64.tar.gz" | sha256sum -c
  3. Unpack it. The release's build script packs llama-server, llama-completion and the other programs into one folder, llama-b12359; if yours unpacks differently, adjust the paths below:
    tar -xzf llama-b12359-bin-ubuntu-x64.tar.gz
    ./llama-b12359/llama-server --version
  4. Download the model from the ggml-org/Qwen3.5-0.8B-GGUF repository on Hugging Face, pinned to the revision checked for this guide (the file is 563,036,064 bytes):
    curl -L -o Qwen3.5-0.8B-Q4_0.gguf https://huggingface.co/ggml-org/Qwen3.5-0.8B-GGUF/resolve/004fd086eccea9f7cf867aa07ba328773beef81d/Qwen3.5-0.8B-Q4_0.gguf
  5. Check it against the SHA-256 that Hugging Face lists on the file's page. It should print Qwen3.5-0.8B-Q4_0.gguf: OK:
    echo "57d1997790d1744fba5b40a7317df71ea5e2acee28c47e78f0cce39c0703f8cf  Qwen3.5-0.8B-Q4_0.gguf" | sha256sum -c
  6. Measure the server. -c 4096 sets a context of 4,096 tokens, plenty for one short prompt. Without it, llama.cpp uses the size the model declares, which for this model is 262,144 tokens. --no-ui turns off the built-in chat app, and --offline stops the server from using the network:
    node measure-model.mjs measure --server -- ./llama-b12359/llama-server -m Qwen3.5-0.8B-Q4_0.gguf -c 4096 --port {port} --no-ui --offline

Shape of the output (not a measurement: your figures replace the words in angle brackets)

measured: ./llama-b12359/llama-server -m Qwen3.5-0.8B-Q4_0.gguf -c 4096 --port {port} --no-ui --offline
server ready after: <seconds> s (start-up and loading)
memory when ready: <size> GB (VmRSS)
time to first token: <seconds> s (from sending the request)
generated: <count> tokens, as counted by the server; text begins: "<the first words of the answer> ..."
generation rate: <rate> tokens per second
the server's own figure: <rate> tokens per second (timings.predicted_per_second)
peak memory: <size> GB (VmHWM)
of which file-backed: <size> GB (RssFile, at the highest sample)

To measure a single run from the command line instead, use output mode with llama-completion. Here -st runs one turn of conversation and exits, -n 128 limits the answer to 128 tokens, and --no-display-prompt keeps your prompt out of the output, so that the first output should be generated text:

node measure-model.mjs measure -- ./llama-b12359/llama-completion -m Qwen3.5-0.8B-Q4_0.gguf -c 4096 -n 128 -st --no-display-prompt --simple-io --offline -p "Explain in three sentences what a language model is."

Check the output begins line: it shows exactly what the meter timed. If it starts with your prompt or a banner rather than the answer, time to first output measured that instead.

Reading the figures

No figures for a real model appear on this page, because Backprop Bulletin did not measure one. This is what each line means, and what to look for in yours:

Where the measurement stops being reliable

A program that holds its output in a buffer

The meter can only time what reaches it. Many programs write their output to a buffer in memory and pass it on in large blocks. The POSIX standard for C's input and output streams says standard output is "fully buffered" when it is not connected to an interactive device, which is exactly the situation when the meter reads it through a pipe. The simulated model can behave like such a program:

    if (!buffered || pending.length >= 4096) {

Measure it with --buffered. It generates its words at exactly the same pace as before, but keeps them in a 4 KB buffer that never fills:

Run

node measure-model.mjs measure -- node measure-model.mjs simulate --buffered

Expected output (simulated model)

measured: node measure-model.mjs simulate --buffered
exit status: 0
time to first output: 6.1 s (includes start-up and loading)
output: 49 words; output begins: "This text comes from the simulated model in ..."
output rate: not measured: the output arrived in 1 read within 0.0 s.
The program may be holding its output in a buffer; see the guide.
peak memory: 0.3 GB (VmHWM)
of which file-backed: under 0.1 GB (RssFile, at the highest sample)

The model was just as fast as before, but the meter now reports a first output 4.8 s later and cannot report a rate. It refuses to guess a rate, but it cannot correct the time to first output: from outside, a slow model and a buffered one look the same. If this happens with your program, make it write as it goes. Python has the -u option for this; for a program that uses the C library's default buffering, stdbuf -oL before the command makes output line-buffered, though it has no effect on a program that sets its own buffering. Server mode avoids the problem, because streaming is part of the request.

A script that starts the model

The meter measures the memory of the process it starts. If that process is a script that starts the model, it measures the script:

Run

node measure-model.mjs measure -- sh -c 'node measure-model.mjs simulate; true'

Expected output (simulated model)

measured: sh -c 'node measure-model.mjs simulate; true'
exit status: 0
time to first output: 1.3 s (includes start-up and loading)
output: 49 words; output begins: "This text comes from the simulated model in ..."
output rate: 10 words per second
peak memory: under 0.1 GB (VmHWM)
of which file-backed: under 0.1 GB (RssFile, at the highest sample)
warning: the measured process started 1 other process; their memory is not included above.
Measure the model program itself, not a script or wrapper that starts it.

The timing is still right, because the model writes to the same output. The memory is the shell's, not the model's 0.3 GB. The ; true keeps the shell running after the model starts; without it, a shell may hand its process over to the model, and the problem would not show. Point the meter at the model program itself.

Clean up

The meter writes no files, and it stops every server it starts. If you followed the steps with a real model, delete the llama.cpp folder, its archive and the model file, then the meter itself:

rm -rf llama-b12359 llama-b12359-bin-ubuntu-x64.tar.gz Qwen3.5-0.8B-Q4_0.gguf measure-model.mjs

If you stopped a measurement with Ctrl+C while a server was running, check that no llama-server is left behind with pgrep -a llama-server, and stop any that is with kill and its process number.

What this does not measure

Sources

Technical statements on this page were checked against these primary sources on 18 November 2026:

About this guide. It was written for this site by Backprop Bulletin with AI assistance. Every checked command above was run as shown, and each expected output is copied from that run; an automated check runs them again. The steps with a real model were not run by Backprop Bulletin for this guide. No outside expert has reviewed it. The worked example uses a simulated model. It needs no account, key, network connection or paid service, and it sends nothing anywhere.