Julia module for CPU timing
Switch branches/tags
Clone or download

README.md

CPUTime.jl

Build Status

A Julia package for measuring elapsed CPU time in Julia.

Installation

You should only use this package if you know what you're doing - CPU time on multi-core processors is a tricky beast. Please at least read the discussion in Issue #1 before proceeding. Once you've done that, to install call:

Pkg.add("CPUTime")

from the Julia command line.

Functions and Macros

The exported functions and macros, as well as their absolute time equivalents, are listed in the following table.

Real time (Julia standard library) CPU time (CPUTime.jl)
time_ns() CPUtime_us()
tic() CPUtic()
toq() CPUtoq()
toc() CPUtoc()
@time @CPUtime
@elapsed @CPUelapsed

Note that the finest resolution for CPU time is microseconds, as opposed to nanoseconds for absolute time.

Usage Example

using CPUTime

function add_and_sleep()
    x = 0
    for i in 1:1e7
        x += i
    end
    sleep(1)
end

@time @CPUtime add_and_sleep()
elapsed CPU time: 0.578552 seconds
elapsed time: 1.580263121 seconds (320166488 bytes allocated, 11.91% gc time)