Class BenchmarkRace
java.lang.Object
ai.redouble.demo.BenchmarkRace
- All Implemented Interfaces:
JobObserver<JobEvent>
One benchmark's race, streamed to the browser as it runs: an observer on the runtime's
message bus, scoped to the race's workflow, that turns every event of the raced runs
and their judges - and of the calls those runs make, attributed by walking each job's
parent chain up to the run the
Benchmark named - into one line of
newline-delimited JSON on the response, the way the chat endpoints stream a
conversation's progress over a socket. The lines borrow the chat wire's frame types:
a status line carrying the plan (one row per run, in race order), a
progress line per event - a terminal one carrying the row's spend so far, summed
from the responses it carries and priced from the catalog; a judge's completion carrying
its score and reason - and workflow_complete with the answer and the report, or
workflow_failed with the failure. A browser that leaves stops the lines and
nothing else: the race runs to its end on the runtime.
The logic is the demo's, shared by every host: a host supplies how a line reaches the
client (sink), how the stream is closed (onEnd), and its own JSON serializer
(toJson), so the wire is the framework's while the trace is one.
- Since:
- 0.1 (2026-09-25)
- Author:
- Andrey Santrosyan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete(BenchmarkOutcome outcome) The last line: the answer and the report, then the stream closes.voidThe last line when the benchmark itself failed, then the stream closes.Returns a predicate for filtering events at the MessageBus level.voidProcess a job event.voidThe first line: every row the race will have, in race order, before any of them has an event.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface JobObserver
isStale
-
Constructor Details
-
BenchmarkRace
public BenchmarkRace(Function<Object, String> toJson, String workflowId, String benchmarkJobId, Consumer<String> sink, Runnable onEnd) - Parameters:
toJson- the host's JSON serializersink- where a rendered line goes, one call per lineonEnd- closes the stream, called once when the last line is written
-
-
Method Details
-
plan
-
getPredicate
Description copied from interface:JobObserverReturns a predicate for filtering events at the MessageBus level. Called once during subscription.- Specified by:
getPredicatein interfaceJobObserver<JobEvent>- Returns:
- predicate to filter events, or null to accept all events of type T
-
observe
Description copied from interface:JobObserverProcess a job event. Runs in a separate virtual thread. Must handle its own resources and exceptions.- Specified by:
observein interfaceJobObserver<JobEvent>- Parameters:
event- the job event to process
-
complete
The last line: the answer and the report, then the stream closes. -
fail
The last line when the benchmark itself failed, then the stream closes.
-