cmyr / cargo-instruments

A cargo plugin to generate Xcode Instruments trace files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing ARGS which begin with `--`?

morrisonlevi opened this issue · comments

I'm trying to run a command like this:

cargo instruments --all-features --bench $bench -t time --profile-time 5

Where --profile-time 5 is supposed to be an argument to the benchmark for criterion: https://bheisler.github.io/criterion.rs/book/user_guide/profiling.html.

However, I get an error:

error: Found argument '--profile-time' which wasn't expected, or isn't valid in this context

I tried the classic -- e.g.

cargo instruments --all-features --bench $bench -t time -- --profile-time 5

I didn't get an error, but the benchmark definitely didn't run for 5 seconds. I'm not sure exactly what happened.

hmm, interesting. In this example, who is supposed to be handling that flag? I don't imagine it's handled by cargo/rustc (since they don't know about criterion) and so I imagine it's being handled by whatever is executed in criterion to handle running a benchmark, but I'm not really sure how that works, and I'm not sure how best to pass arguments to that process. It's even possible that this flag is handled at compile time, and actually modifies the generated binary?

I'm not going to have time to investigate this much myself, but if you're curious to dig into it the first question to figure out would be, basically: who is handling this flag generally? Is it rustc, the criterion bench runner, or the final binary? If it's the bench runner I'm not sure there's an answer, since afaik criterion doesn't get invoked when you run a bench target through cargo instruments; we just ask rustc to build the bench target, it creates an executable, and we run that.