# Profiling \`dune build -w\`

**URL:** <https://discuss.ocaml.org/t/profiling-dune-build-w/12523>\
**Category:** Learning\
**Created:** [July 2, 2023, 2:45am UTC](https://discuss.ocaml.org/t/profiling-dune-build-w/12523 "2023-07-02T02:45:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeroexcuses](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zeroexcuses/32/1692_2.png) [@zeroexcuses](https://discuss.ocaml.org/u/zeroexcuses)\
**Post date:** [July 2, 2023, 2:45am UTC](https://discuss.ocaml.org/t/profiling-dune-build-w/12523/1 "2023-07-02T02:45:56Z")

</div>

Is it possible to tell `dune build -w` to dump profiling data ?

In particular, on every recompile, dump:

1. X = list of all dune libs recompiled

2. for each x in X, dump the time it took to recompile x

3. for each x in X, dump the ancestor (dependencies) of x

Thanks!

---

<div class="post-metadata">

**Author:** ![mooreryan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mooreryan/32/2843_2.png) [@mooreryan](https://discuss.ocaml.org/u/mooreryan)\
**Post date:** [July 2, 2023, 8:04pm UTC](https://discuss.ocaml.org/t/profiling-dune-build-w/12523/2 "2023-07-02T20:04:51Z")

</div>

You could look at dune’s [tracing](https://dune.readthedocs.io/en/stable/advanced/profiling-dune.html) info. It includes timing of the commands that dune runs. Might have what you need.

---

<div class="post-metadata">

**Author:** ![zeroexcuses](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zeroexcuses/32/1692_2.png) [@zeroexcuses](https://discuss.ocaml.org/u/zeroexcuses)\
**Post date:** [July 2, 2023, 11:00pm UTC](https://discuss.ocaml.org/t/profiling-dune-build-w/12523/3 "2023-07-02T23:00:29Z")

</div>

Along the same lines, is there anything I can modify in following dune file to speed up `dune build -w` ?

```auto
(env
 (_
  (js_of_ocaml
   (compilation_mode separate)
   (flags
    (:standard --no-source-map --target-env=browser))
   (build_runtime_flags (:standard)))))

```

---

<div class="post-metadata">

**Author:** ![mooreryan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mooreryan/32/2843_2.png) [@mooreryan](https://discuss.ocaml.org/u/mooreryan)\
**Post date:** [July 3, 2023, 4:52am UTC](https://discuss.ocaml.org/t/profiling-dune-build-w/12523/4 "2023-07-03T04:52:51Z")

</div>

Depending on whether you need everything or just typechecking for quicker dev, you could run `dune build @check -w`. Often I will do this for a while when iterating on something, then switch to an actual build when needed.
