pyserq.run¶
Simulate a compiled program using its seed, workload and run settings.
Each call starts a fresh run and leaves the Program unchanged.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
program |
Program |
Program returned by compile or Program.from_json. |
Returns¶
Report — run metadata, statistics, sample records and JSON
output. The function releases the GIL while simulating, so calls from
Python threads can run in parallel.
Raises¶
ValueError: a trace cannot be loaded or the simulation fails, including an invalid runtime expression or a finite run that misses its deadline.TypeError:programis not aProgram.
A failed claim is recorded in Report.json(); inspect
its claims field to check the result.
Examples¶
import pyserq
source = """
fn main() {
pool reqs { cap 2; }
stage svc : fifo;
workload {
arrive batch(4);
}
server {
hold reqs (cost(reqs, 1)) { run svc (cost(svc, 2)); }
}
gauge occupied = used(reqs);
}
"""
report = pyserq.run(pyserq.compile(source=source, horizon=10))
assert report.ended == 4
assert report.client["response"].samples == [2.0, 4.0, 6.0, 8.0]