I want to get the time every rule costs when executing a bazel build. I found aspect in bazel,use that feature I can print each rule's finish time in log file.
However I found aspect of a rule executing after the rule executing, with that I can't get when a rule start executing.
So Is there any way to extend a rule before it executing?
Bazel has builtin performance profiling which provides lots of details. Run your build with --profile=/tmp/profile.gz
and then load the resulting file into chrome://tracing
in any Chrome instance. You'll get something like this (from the docs):
Note that due to bazelbuild/bazel#12965 you may need to manually un-gzip it before loading into Chrome.
There's also documentation on the profile file format if you want to write a tool to analyze it yourself.