# Code Review: Added logTime to the Debug module

**URL:** https://discourse.elm-lang.org/t/code-review-added-logtime-to-the-debug-module/2669
**Category:** Request Feedback
**Created:** [December 2, 2018, 10:23am UTC](https://discourse.elm-lang.org/t/code-review-added-logtime-to-the-debug-module/2669 "2018-12-02T10:23:10Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![albertdahlin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/albertdahlin/32/868_2.png) [@albertdahlin](https://discourse.elm-lang.org/u/albertdahlin)
#### Post date: [December 2, 2018, 10:23am UTC](https://discourse.elm-lang.org/t/code-review-added-logtime-to-the-debug-module/2669/1 "2018-12-02T10:23:10Z")

</div>

I’ve made a PR adding [logTime](https://github.com/elm/core/pull/1007) to the Debug module in the [elm/core](https://github.com/elm/core) package.

In 0.18 I made a native module with this and I found it [quite useful](https://discourse.elm-lang.org/t/very-useful-function-when-optimizing-render/1517) when tracking down rendering performance issues. Since native modules are not possible in 0.19 I decided to try a PR instead.

I’m asking for feedback on mainly four things:

- Is the implementation correct? This is my first time messing with native js in 0.19
- Is the documentation OK? (English is not my native language).
- Is there a better name than `Debug.logTime`?
- Would you also find this useful?

Of course, any other feedback is also welcome.

Thanks

---

<div class="post-metadata">

### Author: ![malaire](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@malaire](https://discourse.elm-lang.org/u/malaire)
#### Post date: [December 2, 2018, 10:53am UTC](https://discourse.elm-lang.org/t/code-review-added-logtime-to-the-debug-module/2669/2 "2018-12-02T10:53:31Z")

</div>

I would definitely find it useful, and I think that such a function is an essential part of debugging tools. Just few days ago I had a case where my app was having 500ms delays, and I was hoping that function like this would exist. (While I knew quite well where the problem was, I would’ve liked to time some specific parts to get more details.)

While elapsed time is most useful here, I’d prefer function to also output current time with millisecond resolution, so I can compare starting times of different parts of code.

---

<div class="post-metadata">

### Author: ![drathier](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/drathier/32/915_2.png) [@drathier](https://discourse.elm-lang.org/u/drathier)
#### Post date: [December 3, 2018, 5:01pm UTC](https://discourse.elm-lang.org/t/code-review-added-logtime-to-the-debug-module/2669/3 "2018-12-03T17:01:18Z")

</div>

Why not `Debug.currentTime : Time.Posix` or similar so you can do some calculations over your timestamps? You could still print that value.

EDIT: oh, it’s measuring the time taken to execute the wrapped function. Seems a bit vulnerable to js optimisations, but ok. Go for `Debug.measureTime : (() -> b) -> (b, Time.Posix)` then, or something similar.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)
#### Post date: [December 13, 2018, 5:12pm UTC](https://discourse.elm-lang.org/t/code-review-added-logtime-to-the-debug-module/2669/4 "2018-12-13T17:12:09Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
