from wingfoil import ticker, Latency, TracedBytes, Graph
STAGES = ["produce", "encode", "decode", "strategy", "ack"]
def make_payload(seq):
return TracedBytes(f"quote-{seq}".encode(), Latency(STAGES))
def main():
stamp = True
pipeline = (
ticker(0.01)
.count()
.map(make_payload)
.stamp_if("produce", stamp)
.stamp_if("encode", stamp)
.map(lambda t: t) .stamp_if("decode", stamp)
.stamp_precise_if("strategy", stamp)
.stamp_if("ack", stamp)
)
report = pipeline.latency_report_if(STAGES, stamp, print_on_teardown=True)
print("Running latency pipeline for 0.5 seconds...")
Graph([report]).run(realtime=True, duration=0.5)
print("Done.")
if __name__ == "__main__":
main()