Skip to main content

uppercut-presentmon-measure

Runs startup, idle and workload scenarios against a desktop app on Windows, records frame timing with Intel PresentMon, and writes a JSON summary: frame-time percentiles, average fps, dropped frames, frames that missed the display refresh, the cadence at which frames reached the display, and startup marks the app reports. Parsing a PresentMon CSV and summarizing it are plain functions that work on any platform. Launching an app and capturing needs Windows and a PresentMon executable.

Install

pip install uppercut-presentmon-measure

Python 3.10 or newer, no runtime dependencies. You supply PresentMon (the console or the service CLI); pass its path with --presentmon, the presentmon config key, or the PRESENTMON_CLI environment variable. If none is set, PresentMonCli and PresentMon are looked up on PATH.

Example

measure.json:

{
  "presentmon": "C:/tools/PresentMonCli.exe",
  "out_dir": "out",
  "scenarios": [
    {
      "name": "startup",
      "kind": "startup",
      "command": ["my-app.exe"],
      "runs": 5,
      "marks_file": "out/marks.json"
    },
    {
      "name": "idle",
      "kind": "idle",
      "command": ["my-app.exe"],
      "warmup_seconds": 10,
      "capture_seconds": 15,
      "refresh_hz": 60
    },
    {
      "name": "scroll",
      "kind": "workload",
      "command": ["my-app.exe"],
      "warmup_seconds": 10,
      "capture_seconds": 10,
      "workload_command": ["node", "drive-scroll.js"],
      "capture_process_name": "my-app.exe",
      "refresh_hz": 60
    }
  ]
}
uppercut-presentmon-measure run --config measure.json

The summary is printed and written to out/result.json; each capture's raw CSV is kept as out/<name>.csv. Intel's PresentMon service CLI appends the process and a timestamp to the name it is given (out/<name>-app.exe[1234]-<time>.csv); the runner finds that file and reports its path in csv. A single scenario can also come from arguments:

uppercut-presentmon-measure run --kind idle --capture 15 --presentmon PresentMonCli.exe -- my-app.exe

To summarize a CSV you already have, on any platform:

uppercut-presentmon-measure summarize frames.csv --refresh-hz 60

Scenarios

Kind What happens
startup Launches the app runs times (default 3). After each launch it waits for the app to write marks_file, then stops the app. Each mark is reported in milliseconds since launch, with min, median and max across runs.
idle Launches the app once, waits warmup_seconds, then captures capture_seconds of frames with nothing running.
workload Like idle, and starts workload_command when the capture starts. The command's exit code is reported.

The marks file is JSON with epoch milliseconds, either {"marks": {"ready": 1700000000123}} or the flat form {"ready": 1700000000123}. Scenarios other than startup also report marks when marks_file is set.

A capture targets the launched process. Apps that present from a child process (Chromium and Electron present from their GPU process) can be captured with capture_process_name, or with capture_child_match, which finds the launched app's child whose command line contains a text (--type=gpu-process) when the capture starts and captures that pid. PresentMon records nothing while a window is idle and not presenting, so an idle capture can legitimately come back with "frames": 0 and a note.

Frames as the display showed them

FrameTime and msBetweenPresents say when frames were presented. PresentMon's msBetweenDisplayChange says when each one reached the display, which is what a viewer sees: a frame the compositor dropped or merged has an interval of 0 or NA. parse_presentmon_csv reads that column (and TimeInSeconds) into each frame as display_ms and time_s, and summarize_displayed(frames, refresh_hz) summarizes it:

from uppercut_presentmon_measure import parse_presentmon_csv, summarize_displayed

frames = parse_presentmon_csv(open("frames.csv", encoding="utf-8").read())
summarize_displayed(frames, 120)
# {"presents": 412, "displayed": 409, "refreshHz": 120, "periodMs": 8.333,
#  "displayIntervalMs": {"min": ..., "mean": ..., "p50": 8.31, "p90": ..., "p95": ..., "p99": 8.5, "max": 17.1},
#  "lateFrames": 1, "latePct": 0.24, "durationSeconds": 3.41, "displayedFps": 119.9}

A frame is late when its display interval is more than 1.5 display periods. Percentiles are interpolated by default; pass percentile_method="index" for a plain sorted(values)[int(p / 100 * n)] index, the way many hand-written scripts compute them. A scenario with refresh_hz adds the same summary as displayed, and summarize --refresh-hz prints it too.

Scenario options

Option Default Meaning
name the kind Unique name; also the CSV file name.
kind required startup, idle or workload.
command required App command line, as a list.
cwd, env none Working directory and extra environment for the app and the workload.
runs 3 for startup, else 1 Launches for startup.
warmup_seconds 5 Wait after launch before capturing.
capture_seconds 10 Length of the PresentMon capture.
workload_command none Required for workload.
marks_file none Required for startup.
marks_timeout_seconds 30 How long startup waits for marks.
capture_process_name launched pid Capture a process by name.
capture_child_match launched pid Capture the app's descendant process whose command line contains this text, found when the capture starts (waits up to 10 s for it). Not combinable with capture_process_name. The pid is reported as capturedPid.
capture_delay_seconds 0 Seconds between the start of the workload (for idle, the end of the warmup) and the start of the capture. With 0 the capture starts first, then the workload. Above 0 the workload starts first and runs alongside the wait.
refresh_hz none Adds missedRefreshFrames (frames longer than 1.5 refresh intervals) and, when the CSV has a display-change column, the displayed summary below.

Top-level config keys: scenarios, presentmon, out_dir (default out), and presentmon_args (extra arguments appended to every capture command).

Python API

Function Description
parse_presentmon_csv(text, frame_time_column=None) -> list[dict] Frames as {"frame_time_ms", "dropped", "display_ms", "time_s"}. Reads FrameTime or msBetweenPresents; display_ms is msBetweenDisplayChange and time_s is TimeInSeconds, None when missing.
summarize_displayed(frames, refresh_hz, percentile_method="linear") -> dict Display-change cadence: displayed frames, interval percentiles, late frames, displayed fps.
summarize_frames(frames, refresh_hz=None) -> dict Frame count, duration, average fps, frameTimeMs min, mean, p50, p90, p95, p99 and max, dropped frames and percent.
percentile(values, pct, method="linear") -> float Linear-interpolated percentile, or method="index" for a plain index.
summarize_runs(values_ms) -> dict Min, median and max of repeated runs; None counts as a failed run.
summarize_startup_marks(marks, launch_epoch_ms) -> dict Marks as milliseconds since launch.
parse_marks(text) -> dict Reads a marks file.
load_config(path), parse_config(data) Validate a config into Config and Scenario objects.
build_presentmon_command(executable, output_file, seconds, pid=None, process_name=None, extra_args=()) The capture command line.
resolve_presentmon(option=None, env=None) -> str Locate the executable.
find_capture_csv(requested, since=0.0) -> Path or None The CSV a capture wrote: the exact name, or the newest suffixed one written since since.
capture_frames(presentmon, out_csv, seconds, pid=None, process_name=None, delay_seconds=0, extra_args=(), refresh_hz=None) -> dict One capture of a chosen pid or process name, after an optional delay: waits, captures, finds the CSV and returns frames, displayed, csv and presentmonExitCode. For scripts that own their own timeline.
find_descendant_pid(root_pid, command_line_contains, processes=None, timeout_seconds=0) -> int or None The lowest pid among the descendants of root_pid whose command line contains the text.
list_processes() -> list[(pid, parent_pid, command_line)] Running processes; PowerShell on Windows, ps elsewhere.
run_scenario(scenario, presentmon, out_dir, extra_args=()) -> dict Run one scenario. Windows only.

Errors

Error Raised when
ConfigError The config is missing a field or a value has the wrong type.
FrameParseError A CSV has no frame-time column or a non-numeric value.
FileNotFoundError The PresentMon executable cannot be found.
RuntimeError A scenario is run off Windows, or the app exits before the capture starts.

The command line exits with status 2 and prints the message for each of these.

A scenario also raises RuntimeError when capture_child_match finds no child process, or when the app exits during capture_delay_seconds.

On the command line, write the match with an equals sign so the shell does not read it as an option: --capture-child-match=--type=gpu-process. --capture-delay takes seconds.

Changes in 0.2.0

  • Reads msBetweenDisplayChange and TimeInSeconds; new summarize_displayed, and a displayed summary in scenario results and in summarize when a refresh rate is given.
  • New scenario options capture_delay_seconds and capture_child_match, and the matching --capture-delay and --capture-child-match flags.
  • New capture_frames, find_descendant_pid and list_processes; scenario results report capturedPid.
  • percentile takes method. Parsed frames carry two more keys (display_ms, time_s).

License

MIT

Metadata

Release files for uppercut-presentmon-measure 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uppercut-presentmon-measure 0.2.0
File Size Uploaded Provenance Actions
uppercut_presentmon_measure-0.2.0.tar.gz 22.3 kB Without provenance Details for uppercut_presentmon_measure-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for uppercut-presentmon-measure 0.2.0
File Interpreter ABI Platform Actions
uppercut_presentmon_measure-0.2.0-py3-none-any.whl Python 3 none any Details for uppercut_presentmon_measure-0.2.0-py3-none-any.whl

Total release size: 40.9 kB

Release files / uppercut_presentmon_measure-0.2.0.tar.gz

Download URL uppercut_presentmon_measure-0.2.0.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2e12f082f26e9ac5c16480f6f93ce5ea281a86d76d178fb7e785cb5902af3ae5
BLAKE2b-256 checksum
How to use checksums
16101e5dc3b251c05bf5ec9eb6cfaee4f7f174fca910e1b38a595783b65f21bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / uppercut_presentmon_measure-0.2.0-py3-none-any.whl

Download URL uppercut_presentmon_measure-0.2.0-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8cf1ffd745069db2b79d49e8c09b45f513c23b4cb73b6fc5e5818cca7f73debb
BLAKE2b-256 checksum
How to use checksums
f87ad2c17c60528e7dd88b814519f9f146f77348350b178c3f4a4fb5c6ccb50d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for uppercut-presentmon-measure 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page