简体   繁体   English

GNU Make-如何添加时间戳输出(只需最少的makefile修改)

[英]GNU Make - how to add timestamp output (with minimal makefile modification)

I want to get a better idea of my build job metrics but unfortunately, make doesn't output timestamps per se. 我想更好地了解我的构建作业指标,但是不幸的是, make本身并不输出时间戳。

If I run make --print-data-base , for a given target it outputs a line 如果我运行make --print-data-base ,对于给定的目标,它将输出一行

#  Last modified 2016-08-15 13:53:16

but that doesn't give me the duration. 但这并没有给我持续时间。

QUESTION

Is there a way to get duration of building a target without modifying each target? 有没有办法在不修改每个目标的情况下获得建立目标的持续时间? Some targets are inside makefiles which are generated DURING the build so not feasible to modify their recipes. 有些目标位于makefile中,这些文件是在构建期间生成的,因此无法修改其配方。

POSSIBLE SOLUTION 可能的解决方案

I could implement a pre- and post-recipe for every target and output a timestamp that way. 我可以为每个目标实现前后配方,并以这种方式输出时间戳。

Is that a good idea given this is parallel make ? 鉴于这是并行make这是一个好主意吗? Obviously there would be increased build time from calling a pre- and post-recipe for every target but I'd be fine with that. 显然,通过为每个目标调用前和后食谱会增加构建时间,但我对此表示满意。

If this is a parallel make, then the "preactions", "actions" and "postactions" may be interleaved. 如果这是并行生成,则可以将“前置”,“动作”和“后置动作”进行交错。 That is, you might get output like: 也就是说,您可能会得到如下输出:

Pre-action 12:03:05
Pre-action 12:03:06
building foo...
building bar...
Post-action 12:04:17
Post-action 12:04:51

So it would behoove you to pass a TARGETNAME variable to the pre-action and post-action scripts. 因此,您应该将TARGETNAME变量传递给操作前和操作后脚本。

Also, start and end times are not all there is to know about how long an action takes, when you are running things in parallel; 同样,当您并行运行事物时,开始和结束时间并不是仅知道一个动作需要多长时间。 rule A might take longer that rule B, simply because rule B is running alone while rule A is sharing the processor with rules C through J. 规则A可能需要比规则B更长的时间,这仅仅是因为规则B是单独运行,而规则A通过J与规则C共享处理器。

Other than that, I see no problem with this approach. 除此之外,我认为这种方法没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM