Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

performance-utils

Measure the performance (latency) of your hosted software across all 7 layers of the OSI model, and see where you can optimize.

Two Python scripts, stdlib-only, work on Windows / macOS / Linux:

File Purpose
network_layers_latency.py Prints a plain-text 7-layer latency gauge in the terminal.
html_report.py Runs the same measurements and writes a self-contained HTML report with an Ask Gemini panel.

Layers measured

Layer OSI layer What it measures
L1 Physical Local NIC link speed (Wi-Fi / Ethernet)
L2 Data Link Local MAC address and per-interface byte counters
L3 Network ICMP ping + traceroute to the target host
L4 Transport TCP connect latency to the target host:port
L5 Session TLS handshake negotiation time
L6 Presentation Negotiated TLS cipher + protocol version
L7 Application HTTP request: DNS+TCP+TLS, TTFB, and total time

L5 and L6 share one measurement when the URL is https://; for plain http:// there is no TLS.

Requirements

  • Python 3.8+ — no third-party packages, standard library only.
  • A network connection to the target URL.
  • Optional: traceroute on Linux/macOS, PowerShell Get-NetAdapter on Windows (for richer L1/L2 detail).

Quick start

# Default target (Google's 204 endpoint)
python network_layers_latency.py

# Plain-text measurement of your own URL
python network_layers_latency.py --url https://my-webapp.example.com

# Self-contained HTML report
python html_report.py --url https://my-webapp.example.com --html report.html

You can also set the target via TARGET_URL env var.

Options (both scripts)

Flag Long Default Description
-u --url env / Google 204 Target URL to measure.
-n --pings 4 Number of ICMP ping packets (L3).
-H --hops 5 Max traceroute hops (L3).
-t --timeout 5 Per-command / socket timeout (seconds).
-o --html stdout html_report.py only: write report to this path.
--model gemini-3.6-flash html_report.py only: model pre-filled in the Ask Gemini panel.

Ask Gemini

Every HTML report includes an Ask Gemini panel at the bottom. To use it:

  1. Get a free API key at Google AI Studio.
  2. Open the report in your browser, paste the key into the panel, edit the question if you want, and click Ask Gemini.

The key is stored only in this browser's localStorage and sent directly from your browser to Google's API — nothing passes through any other server. The model defaults to gemini-3.6-flash and can be changed per call.

Interpreting results

  • L4 high, L3 low → server-side TCP accept queue / SYN handling.
  • L5/L6 high → certificate chain, TLS version, client CPU. TLSv1.3 should be fast.
  • L7 TTFB − (L4+L5+L6) large → application server is slow before sending any body (DB query, render, upstream call, etc.).

Notes

  • L1/L2 are inherently local-machine measurements. L3–L7 measure the path to the target URL.
  • The scripts are dependency-free so they run anywhere Python does.

About

Measure performance of your hosted software at different levels, see what you can optimize.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages