如何使用ocamlc选项-dprofile和-dtimings?

时间:2018-11-02 06:02:11

标签: ocaml

我知道我可以使用一些ocamlc选项,例如-dparsetree来查看解析器生成的AST。

我可以看到ocamlc具有选项-dprofile-dtiming。 ocamlc -h告诉我选项-dprofile有四列:time alloc top-heap absolute-top-heap。我试图这样使用它:

ocamlc -c test.ml -dprofile time

但是ocamlc向我显示了-h信息,所以可能不正确。

您能告诉我如何使用选项-dprofile----dtimings或向我展示一些示例吗? ocaml的文档中和互联网上都没有几个示例。谢谢!

1 个答案:

答案 0 :(得分:1)

我对这些选项一无所知。我怀疑它们是开发人员未公开的内部选项。实际上,这可能意味着它适合您。看来您是一名开发人员。

无论如何,这些命令为我产生了一些输出:

$ ocamlc -dprofile -c m.ml
0.004s 1.28MB ------ - m.ml
  0.002s 0.85MB ------ - typing
  ------ 0.03MB ------ - transl
  0.001s 0.38MB ------ - other
0.013s 0.33MB 3.75MB - other

$ ocamlc -dtimings -c m.ml
0.004s m.ml
  0.003s typing
  0.001s other
0.007s other

我不明白您为什么要使用参数time。但这可能是问题所在。单独指定-dprofile-dtimings似乎都可以。如果两者都指定,则最后指定的那个优先。

相关问题