pyserq.Report¶
The result of run. Report() is not a public constructor.
Its attributes are read-only.
Attributes¶
| Attribute | Type | Description |
|---|---|---|
serq_version |
str |
Version of the interpreter that ran the program. |
horizon |
float |
Configured simulation deadline. |
end |
float |
Actual end time; may be earlier for a finite arrival-limited run. |
warmup |
float |
Warm-up cutoff for measured statistics. |
seed |
int |
Run seed. |
events |
int |
Number of events processed. |
arrivals |
int |
Sessions that arrived. |
ended |
int |
Sessions that ended. |
turns |
int |
Turns counted by the run. |
mean_live |
float |
Time-average number of live sessions after warm-up. |
observes |
dict[str, Observe] |
Observations in program order. A new dictionary on each access. |
client |
dict[str, Observe] |
What each turn's client saw: ttft, tpot and response, in that order, whatever the program observes (client metrics). A new dictionary on each access. |
gauges |
dict[str, Gauge] |
Gauges in program order. A new dictionary on each access. |
claims |
dict[str, Claim] |
Claims in program order; empty when the program has none. A new dictionary on each access. |
stages |
list[Stage] |
One row per stage or array member. A new list on each access. |
pools |
list[Pool] |
One row per pool or array member. A new list on each access. |
Python float attributes preserve NaN and infinities. JSON encodes these as
null.
Methods¶
| Method | Returns | Description |
|---|---|---|
json() |
str |
JSON summary matching the CLI. |
observe(name) |
Observe or None |
Observation by name. |
gauge(name) |
Gauge or None |
Gauge by name. |
claim(name) |
Claim or None |
Claim by name. |
stage(name) |
Stage or None |
First stage row with this name. |
stages_named(name) |
list[Stage] |
All stage array members, in index order. |
pool(name) |
Pool or None |
First pool row with this name. |
pools_named(name) |
list[Pool] |
All pool array members, in index order. |
All lookup methods take name: str, the declaration's name. Use "svc",
not "svc[0]", for an array; select members by their index.
A non-string name raises TypeError. A missing name returns None for
single-object lookups or an empty list for plural lookups.
json¶
Return the JSON summary produced by serq run --json. Parse it with
json.loads. Samples and gauge change points are available through the
objects below rather than embedded in this summary. The schema is
versioned by REPORT_VERSION.
observe¶
Return the named Observe, or None.
gauge¶
Return the named Gauge, or None.
claim¶
Return the named Claim, or None.
stage¶
Return the first Stage row with this name, or None. For an
array, use stages_named to inspect every member.
stages_named¶
Return all Stage rows with this name in index order, or [].
A scalar stage has one row whose index is None.
pool¶
Return the first Pool row with this name, or None.
pools_named¶
Return all Pool rows with this name in index order, or [].
A scalar pool has one row whose index is None.
Examples¶
import pyserq
source = """
fn main() {
pool reqs { cap 2; }
stage svc : fifo;
workload {
arrive batch(4);
}
server {
set t0 = now;
hold reqs (cost(reqs, 1)) { run svc (cost(svc, 2)); }
observe response = now - t0;
}
gauge occupied = used(reqs);
}
"""
report = pyserq.run(pyserq.compile(source=source, horizon=10))
import json
assert report.pool("reqs").admissions == 4
assert report.stage("svc").completed == 4
assert report.observe("missing") is None
assert report.pools_named("missing") == []
summary = json.loads(report.json())
assert summary["ended"] == report.ended