gpt4 book ai didi

scala - 如何分析在SBT中完成任务所花费的时间

转载 作者:行者123 更新时间:2023-12-04 09:03:50 24 4
gpt4 key购买 nike

我想知道为什么有时我的构建速度要慢得多。

因此,我决定测量长时间运行的任务。

当运行纯Scala代码时,这样做很容易:

def myMethod() = {
val initTime = System.currentTimeMillis
...
val elapsedTime = System.currentTimeMillis-initTime
}

但是对于像 packageBincompile这样的源代码我无法更改的任务,我不知道如何衡量它,因为我无法控制 someTask.value的运行时间。

有什么提示吗?

相关问题:
  • Profiling sbt builds
  • 最佳答案

    为了进行更完整的分析,您还可以使用 jrudolph/sbt-optimizer/

    sbt-optimizer is an experimental plugin that hooks into sbt's task execution engine and offers a graphical ASCII report once a tree of tasks has been run

    Add the plugin to project/plugins.sbt:


    addSbtPlugin("net.virtual-void" % "sbt-optimizer" % "0.1.2")

    and enable it in a project with:


    enablePlugins(net.virtualvoid.optimizer.SbtOptimizerPlugin)

    https://raw.githubusercontent.com/jrudolph/sbt-optimizer/master/docs/example-line.png

    Each output line corresponds to one task that has been executed.

    • The first time is the total time this task was running.
    • The second time displayed in green is the actual execution time.
    • The third time displayed in red is time the task wanted to run but was waiting for the global ivy lock.
    • The last time displayed in cyan is the time the task was blocked waiting for Ivy downloads.

    关于scala - 如何分析在SBT中完成任务所花费的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32588234/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com