Ocaml 询问程序的运行时间

Ocaml 询问程序的运行时间,ocaml,coq,Ocaml,Coq,我编写了一个解析器程序(用OCaml编写),该程序接受的输入是一个xsd,然后将其生成到Coq文件中。但在终端中生成需要花费大量时间(~:0m.0152s)。我想知道一些能让praser跑得更快的建议?例如,使程序变慢的原因是什么?这是我第一次面对这个运行时间问题。因此,我非常感谢您的任何建议/经验 多谢各位 编辑: 我可以试着用主文件来解释: open Libxml;; (*it is the library for xml file*) open Error;; (* it is for t

我编写了一个解析器程序(用OCaml编写),该程序接受的输入是一个xsd,然后将其生成到Coq文件中。但在终端中生成需要花费大量时间(~:0m.0152s)。我想知道一些能让praser跑得更快的建议?例如,使程序变慢的原因是什么?这是我第一次面对这个运行时间问题。因此,我非常感谢您的任何建议/经验

多谢各位

编辑: 我可以试着用主文件来解释:

open Libxml;; (*it is the library for xml file*)
open Error;; (* it is for the error message*)

let main () =     
  let xml = parse_xml stdin in
  let xsds = Xsd_of_xml.xsd_of_xml xml in (* It is a parsing from xml to xsds *)
  let b = Buffer.create 10000 in

  Coq_of_xsd.genr_coq b xsds; (* It is a parsing from xsds to Coq type *)
  Buffer.output_buffer stdout b;;

let _ = run main;;
我编写了一个
Makefile.xsd2coq
如下:

MAIN := xsd2coq

FILES := util error libxml xsd scc xsd_of_xml coqxsd_matrix coqxsd_print coq_of_xsd

FRAGILE_FILES := xsd coqxsd_matrix coqxsd_print coq_of_xsd

LIBS := xml-light/xml-light

INCLUDES := -I xml-light

coq_of_xsd.cmo coq_of_xsd.cmx libxml.cmo libxml.cmx: WARNINGS = -warn-error Aezk

include Makefile.ocaml
在main中:
Makefile

xsd2coq: FORCE
    $(MAKE) -f Makefile.xsd2coq depend
    $(MAKE) -f Makefile.xsd2coq

当我测试我使用的解析器组合器时。我已经看到70%的时间都花在了区块分配上。也许探查器的输出将帮助您发现类似的问题。

请解释如何测量时间,也许我们可以帮助您。如果从一开始(即时间)算起是0.0152s,那么会有很多事情发生(设置运行时和初始化vm),您运行的代码可能很卑劣。这很有帮助。非常感谢卡卡杜。