StanfordLegion / prof-viewer

Legion Prof Viewer
Apache License 2.0
0 stars 5 forks source link

Use common log prefix for window title #28

Closed bryevdv closed 11 months ago

bryevdv commented 1 year ago

This PR adds support to attempt to extract a common path prefix for log files provided on the command line, to use for the window title. If a common prefix is not determinable, the default "Legion Prof" is retained. cc @lightsighter

This PR also applies some some fixes advised by clippy regarding or_default.

cc @elliottslaughter is there a more robust rust solution for pruning command line options than this?

if !argument.starts_with("--") { ... }

Usage

Invoked with

RUST_BACKTRACE=1 target/debug/legion_prof --view ~/work/proflogs/231034/*.prof

produces:

Screenshot 2023-10-09 at 14 26 48
elliottslaughter commented 1 year ago

This is not going to work because we don't know how we're being called, or if the arguments are even being supplied on the command line. If we want to do this, we'll need to augment the DataSource interface to add a new trait method like:

fn get_source_path(&self) -> Option<PathBuf>;

Except I'm still not sure I'm happy with this because it might be a URL, not a Path at all. Maybe, to keep things consistent, we should just make this a String:

fn get_source_locator(&self) -> Option<String>;

And accept that the conversion into String will be lossy (i.e., not every Path can be converted to String because some OSes use non-UTF8 paths).

bryevdv commented 1 year ago

👍 That will be much cleaner