# Measuring elapsed CPU time / equivalent to clock()?

**URL:** https://discourse.julialang.org/t/measuring-elapsed-cpu-time-equivalent-to-clock/18735
**Category:** New to Julia
**Created:** [December 17, 2018, 9:50am UTC](https://discourse.julialang.org/t/measuring-elapsed-cpu-time-equivalent-to-clock/18735 "2018-12-17T09:50:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![fa-bien](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fa-bien/32/5559_2.png) [@fa-bien](https://discourse.julialang.org/u/fa-bien)
#### Post date: [December 17, 2018, 9:50am UTC](https://discourse.julialang.org/t/measuring-elapsed-cpu-time-equivalent-to-clock/18735/1 "2018-12-17T09:50:33Z")

</div>

I want to measure the total CPU time elapsed. I do not believe that I use any multi-threaded operation. In Python I would use time.clock() for this; in C, clock(). I have looked at @time and @elapsed macros but they do not work for me for two reasons:

- they measure wall time
- they do not provide the time elapsed since the program started. time\_ns() does that but for wall time.

So basically I would like something like time\_ns() but for CPU time rather than wall time. Is there a function that provides this functionality? If not, how should I go about writing one?

---

<div class="post-metadata">

### Author: ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)
#### Post date: [December 17, 2018, 10:38am UTC](https://discourse.julialang.org/t/measuring-elapsed-cpu-time-equivalent-to-clock/18735/2 "2018-12-17T10:38:31Z")

</div>

You might want to take a look at [GitHub - schmrlng/CPUTime.jl: Julia module for CPU timing](https://github.com/schmrlng/CPUTime.jl)

---

<div class="post-metadata">

### Author: ![fa-bien](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fa-bien/32/5559_2.png) [@fa-bien](https://discourse.julialang.org/u/fa-bien)
#### Post date: [December 17, 2018, 10:42am UTC](https://discourse.julialang.org/t/measuring-elapsed-cpu-time-equivalent-to-clock/18735/3 "2018-12-17T10:42:27Z")

</div>

Thank you, don’t know how I missed that, CPUtime\_us() is what I need!
