cmyr / cargo-instruments

A cargo plugin to generate Xcode Instruments trace files
MIT License
665 stars 34 forks source link

Piping into and out of the profiled binary #25

Open walles opened 3 years ago

walles commented 3 years ago

I want to profile this command line:

riff < /tmp/glp.txt > /dev/null

How can I do that using cargo instruments?

Riff is a filter that reads data from stdin and prints it to stdout.

If I just start riff using cargo instruments, ptop says that riff's stdin and stdout are both connected to instruments, which is not what I want.

How do I tell cargo instruments how to set up stdin and stdout for the profiled binary?

cmyr commented 3 years ago

I believe that instruments itself consumes stdin and stderr; you can verify this by running instruments directly and seeing if there's any way to get your binary's output? Assuming this is the case I don't know how to work around this. :(

walles commented 3 years ago

I didn't get it working.

This I think should have worked, but it didn't:

xcrun xctrace record --template "Time Profiler" --target-stdin - --target-stdout - --launch -- target/debug/riff
walles commented 3 years ago

What I did as a workaround BTW was:

Then scroll down to riff in the Instruments UI and see what happened.

cmyr commented 3 years ago

you should consider opening a radar with apple (or whatever the new version of radar is) in which case send me the number and I'll file a dupe.