Add a separate --profile-startup option to profile startup

This goes to a separate file because that makes option parsing easier
and allows profiling both at the same time.

The "normal" profile now contains only the profile data of the actual
run, which is much more useful - you can now profile a function by
running

   fish -C 'source /path/to/thing' --profile /tmp/thefunction.prof -c 'thefunction'

and won't need to filter out extraneous information.
This commit is contained in:
Fabian Homborg
2021-01-08 17:25:00 +01:00
parent cf800db10a
commit 594d51e7eb
6 changed files with 56 additions and 3 deletions

View File

@@ -272,6 +272,10 @@ static void print_profile(const std::deque<profile_item_t> &items, FILE *out) {
}
}
void parser_t::clear_profiling() {
profile_items.clear();
}
void parser_t::emit_profiling(const char *path) const {
// Save profiling information. OK to not use CLO_EXEC here because this is called while fish is
// exiting (and hence will not fork).