# Benchmarking TKTail on your PC

Every published TKTail figure comes from a deterministic workload and a versioned scenario, measured
on a named machine with the released `TKTail.exe`. You can repeat the measurements: each release's
**Benchmark Kit** (`TKTail-<version>-benchmark-kit.zip`, a separate download beside the package on
the [download page](https://tktail.dev/download/)) holds the same generator, the same harnesses, the
scenarios and the published baseline to compare with.

## Which tool answers which question

| Tool | The question | In the kit |
|---|---|---|
| **TKTail Log Generator** (`TKTailLogGen.com`, window: `TKTailLogGen.exe`) | What is the workload? The same records on every PC: format, rate, record size, multi-line records, rotation, a growing file | `tools\` |
| **Performance Lab** (`tktail_perflab.exe`) | Does TKTail keep up with a growing log on this PC - nothing lost, the window responsive? | `tools\` |
| **Release benchmark** (`tktail_release_bench.py`) | How long do opening a 1 GB log, searching it and starting TKTail take; what does following cost? | `release-benchmark\` |

The published open and search figures come from the release benchmark; the LIVE verdicts from the
Performance Lab. A third tool, `tktail_bench`, measures single internal engines (scanning, decoding,
matching) for TKTail's developers: its numbers describe code paths, not the application, and it is
not in the kit.

## Before you start

Extract the TKTail package and the kit side by side, in a folder you can write to (not *Program
Files*) - *Extract All* gives each ZIP its own folder:

```
C:\Bench\TKTail-<version>\TKTail.exe
C:\Bench\TKTail-<version>-benchmark-kit\README.txt
```

- Use the kit of the same version as the `TKTail.exe` you measure.
- Run the commands from the kit's folder, in a desktop session: the harnesses start TKTail windows.
  Leave the PC alone while they run, and close what keeps it busy.
- On a laptop, plug it in and use the same power plan for every run.
- Your own TKTail is never touched: every run starts a private copy of `TKTail.exe` in its own
  portable sandbox, with its own settings.
- Check the files first: `Get-FileHash tools\TKTailLogGen.com -Algorithm SHA256` must print the
  value of `SHA256SUMS.txt`.

## 1. Generate the workload

```
tools\TKTailLogGen.com run live-applog-1000 -o live.log --duration 10
tools\TKTailLogGen.com generate -o big.log --format applog --size 1GB --rate max --timestamps synthetic --seed 7
```

Every record comes from the scenario's seed. With `--timestamps synthetic` the file is the same
byte for byte on every PC; the second line writes the 1 GB application log of the published open
and search figures. The generator writes into an existing folder only, never replaces a file
without `--overwrite`, and never starts a run that would leave less than 2 GB free (`--dry-run`
shows its plan). The harnesses below generate their own data the same way - this step
is for looking at the data, or for your own tests ([Testing with generated
logs](https://tktail.dev/help/testing-with-generated-logs/)).

## 2. Measure

### Performance Lab: following a growing log

```
tools\tktail_perflab.exe suite normal --repeat 2 --tktail ..\TKTail-<version>\TKTail.exe
```

The `normal` suite runs ten scenarios - application logs at 500 to 10,000 records/s, plain text,
multi-line records, JSON Lines, an alert rule - twice each, about 15 minutes. Each run writes 5 MB of history,
starts TKTail on it, writes the live part at the scenario's rate while TKTail follows, then checks
that every record arrived exactly once. `tools\tktail_perflab.exe list` shows the other suites; one
scenario: `tools\tktail_perflab.exe run applog-500b@1000-A --repeat 2 --tktail ..\TKTail-<version>\TKTail.exe`.

Each run gets a verdict:

| Verdict | Means |
|---|---|
| **SUSTAINABLE** | TKTail kept up: the backlog stayed small and caught up, nothing was lost or duplicated, the window answered within 100 ms (95th percentile), memory did not grow by more than 64 MB |
| **UNSUSTAINABLE** | TKTail fell behind, the window was too slow, or memory kept growing |
| **WRITER-LIMITED**, **STORAGE-LIMITED** | The generator could not write at the scenario's rate on this PC - the run says nothing about TKTail |
| **INVALID-CORRECTNESS** | A record was missing, duplicated or framed wrongly |
| **NOT-TESTED** | The whole PC was at least 95 % busy during the measurement - run it again on a quieter PC |
| **FAILED**, **ABORTED-SAFETY** | The run could not be done, or the disk reserve stopped it |

Only the verdict says whether a run passed: the Lab ends normally for every verdict except FAILED.
Results go to `tools\perflab\results\`: `<run>.json` (every figure and the PC it ran on) and
`<run>.md` (the same as a report).

### Release benchmark: open, search, LIVE cost

It needs Python 3 (64-bit) from [python.org](https://www.python.org/):

```
py release-benchmark\tktail_release_bench.py --exe tktail=..\TKTail-<version>\TKTail.exe --rounds 5 --only huge,v1,live --out release.json
```

It generates about 1.2 GB of data in the kit's `work\` folder (`--work` names another), then starts
TKTail with the 1 GB log, searches it, reads the record at a byte offset, opens the last 2,000
events of the System log, follows a growing log at three rates and measures CPU and memory - from
outside the program, over its command line, window messages and its [MCP](https://tktail.dev/help/mcp/) interface. Times
are medians over the rounds. The script has four more workloads - `startup`, `idle`, `metrics` and
`combined`; `metrics`, `combined` and the restored workspace of `startup` include
[Metrics](https://tktail.dev/help/metrics/) views, which need a Trial or Pro license (`--license <file>`), so the quick
start above leaves them out.

## 3. Compare with the published baseline

```
tools\tktail_perflab.exe table baseline\performance-lab\results
tools\tktail_perflab.exe table tools\perflab\results
tools\tktail_perflab.exe compare baseline\performance-lab\results\<baseline run>.json tools\perflab\results\<your run>.json
py release-benchmark\compare.py release.json baseline\release-benchmark\results\final-v1-confirm.json
```

`table` prints one row per run - the published runs, then yours, scenario by scenario; `compare`
sets two runs of the same scenario side by side. `compare.py` prints each measure of the release
benchmark - yours, the baseline's and the ratio. `baseline\<id>\environment.json` names the
machine, the build, the rounds, the cache state and how busy the machine was. Results are compared
within one workload version only (`kit.json`).

## Reading the numbers

- **Warm or cold.** The published figures are *warm*: the files had been read before and Windows
  had them in memory. The first open after a restart reads from the disk and takes longer - more on
  a hard disk or a network share. No cold-cache figure is published yet.
- **One core, not the machine.** CPU is given in percent of *one* core: 20 % means a fifth of one
  core. On a PC with 16 logical processors that is about 1.3 % of the whole machine.
- **Memory.** The figures are private memory - what TKTail itself holds, not the file cache
  Windows keeps for the log. Opening a huge log adds its line index, not the file.
- **Your machine is not ours.** Another CPU, disk, power plan, antivirus or a busy desktop changes
  every time. When every ratio is far from 1 in the same direction, it is usually the machine, not
  TKTail. An antivirus that scans each new copy of `TKTail.exe` slows its first start; the harnesses
  start it once, unmeasured, before they measure.
- **A benchmark, not a promise.** Real logs differ from generated ones in record sizes, formats and
  how they are written. The numbers show how TKTail behaves under a known load on one PC.

## Limitations

- A kit measures the `TKTail.exe` of its release; compare a version only with its own baseline.
- The baseline was measured on one development PC, under the load its `environment.json` states.
- No figures exist yet for a cold file cache, a network share or Windows 10.

---

The HTML page: https://tktail.dev/help/benchmarking/
