在 Scala 和 SBT 中调试较长的编译时间 [英] Debug long compile times in Scala and SBT

查看:37
本文介绍了在 Scala 和 SBT 中调试较长的编译时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Scala/SBT 项目中,我有一个文件需要 5(!) 分钟来编译.所有其他的都可以在几秒钟内编译.这使得开发非常痛苦.

In my Scala/SBT project, I have one file that takes up to 5(!) minutes to compile. All the other ones can compile in a few seconds. This makes development pretty painful.

我确定我在滥用一些 Scala 结构,但我不知道如何调试它.在 Scala 中如何调试较长的编译时间?

I'm sure that I'm abusing some Scala constructs, but I have no idea how to go about debugging it. How does one debug long compile times in Scala?

我使用的是 Scala 2.9.2 和 SBT 0.11.2

I'm using Scala 2.9.2 and SBT 0.11.2

推荐答案

您可以尝试以下 Scala 编译器选项:

You can try the following Scala compiler options:

  • -Ystatistics 打印编译器统计数据
  • -Ystatistics Print compiler statistics

找到一个花费最多时间的阶段.然后,试试那些:

Find a phase that takes the most time. Then, try those:

  • -Xprint:<phase> 在或全部"之后打印出程序
  • -Yshow-trees 与 -print:phase 结合使用时显示详细的树
  • -Ydebug 输出调试信息
  • -Ypmat-debug 跟踪所有模式匹配器活动.
  • -Xprint:<phase> Print out program after or "all"
  • -Yshow-trees Show detailed trees when used in connection with -print:phase
  • -Ydebug Output debugging messages
  • -Ypmat-debug Trace all pattern matcher activity.

要直接从 sbt 控制台启用这些设置,您可以使用 set scalacOptions in ThisBuild += "-Ystatistics",或者对于多个,set scalacOptions in ThisBuild ++=Seq("-Yshow-trees", "-Ydebug)

To enable these settings directly from the sbt console, you can use set scalacOptions in ThisBuild += "-Ystatistics", or for more than one, set scalacOptions in ThisBuild ++= Seq("-Yshow-trees", "-Ydebug)

这篇关于在 Scala 和 SBT 中调试较长的编译时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆