feat(tvix/eval/observer): Allow capturing timing of events
Add a new --trace-runtime-timing flag (probably a better bikeshed for this) that enables capturing the time, relative to the last event, of each event recorded with the tracing observer. This probably isn't *super* useful yet, but I'd like to start here in adding new profiling tools to the VM, specifically based on the runtime observer Change-Id: Id7f12077291c39bf3eef42ab6744bfba53687a65 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10713 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
3c92a5abf8
commit
6f9e25943f
2 changed files with 36 additions and 0 deletions
|
|
@ -31,6 +31,11 @@ struct Args {
|
|||
#[clap(long, env = "TVIX_TRACE_RUNTIME")]
|
||||
trace_runtime: bool,
|
||||
|
||||
/// Capture the time (relative to the start time of evaluation) of all events traced with
|
||||
/// `--trace-runtime`
|
||||
#[clap(long, env = "TVIX_TRACE_RUNTIME_TIMING", requires("trace_runtime"))]
|
||||
trace_runtime_timing: bool,
|
||||
|
||||
/// Only compile, but do not execute code. This will make Tvix act
|
||||
/// sort of like a linter.
|
||||
#[clap(long)]
|
||||
|
|
@ -113,6 +118,9 @@ fn interpret(code: &str, path: Option<PathBuf>, args: &Args, explain: bool) -> b
|
|||
|
||||
let mut runtime_observer = TracingObserver::new(std::io::stderr());
|
||||
if args.trace_runtime {
|
||||
if args.trace_runtime_timing {
|
||||
runtime_observer.enable_timing()
|
||||
}
|
||||
eval.runtime_observer = Some(&mut runtime_observer);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue