如何对maven执行的不同阶段进行计时
我有一个 Maven 构建,速度非常慢。我想知道是否有一种方法可以分析 Maven 的执行情况,以便找出哪些是最耗时的步骤。
稍后我将想要比较旧版本(速度更快)的构建之间的这些时间,因此理想情况下它们应该采用可以比较/比较/绘制图表的格式。
I have a maven build that is extremely slow. I would like to know whether there is a way to profile maven execution in order to find out which are the most time-consuming steps.
Later I will want to compare these times between builds for older versions (which were faster), so they should be ideally in a format that can be compared/diffed/graphed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是最快的方法:
结果
如果您随后将该环境变量添加到 shell 的配置文件(如
~/.bashrc
或~/.profile
)中,您将获得每次使用 Maven 时的这些时间。基于 Stanley Hillner 博客的信息:< /a>
This is the quickest possible way:
Results in
If you then add that environment variable to your shell's config file (like
~/.bashrc
or~/.profile
) you will have those timings every time you use Maven.Based on info from Stanley Hillner's blog:
开箱即用的解决方案是 takari maven profiler:
https://github.com/takari/maven-profiler
其页面的示例输出:
Out of the box solution is the takari maven profiler:
https://github.com/takari/maven-profiler
Sample output from its page:
https://github.com/jcgay/maven-profiler 是一个类似的方便工具。它易于设置和使用。 (在核心 Maven 中拥有类似的东西或 EventSpy takari/maven-profiler 作为一个选项肯定会很简洁;评论 https://issues.apache.org/jira/browse/MNG-4639 ..)
https://github.com/jcgay/maven-profiler is a similar handy tool. It's easy to setup and use. (Having something like it or EventSpy takari/maven-profiler in core Maven as an option would certainly be neat; comment in https://issues.apache.org/jira/browse/MNG-4639 ..)
该功能已包含在 Maven3 中。这是相关的票证: https://issues.apache.org/jira/browse/MNG -4639
如果您需要对 Maven2 执行相同的操作,我建议您构建自己的插件,该插件可以挂钩到执行的所有阶段(或者只是您需要跟踪的阶段)。
This functionality has been included in Maven3. Here's the associated ticket: https://issues.apache.org/jira/browse/MNG-4639
If you need to do the same with Maven2 I'd recommend building yor own plugin that is hooks into all phases of execution ( or just the ones you need to track).
我只是在这里创建一个要点: https://gist.github.com/boly38/7316378
这是一个关于如何记录某些 maven 生命周期的日期时间的示例步骤。
当然,您可以调整此示例来设置您自己的输出格式(并绘制图表......)。
希望这有助于
提取:
i just create a gist here : https://gist.github.com/boly38/7316378
This is a sample example on how to log datetime of some maven lifecycle steps.
Of course you could adapt this sample to set your own output format (and graph it ...).
Hope this help
Extract :