Skip to content

schmrlng/CPUTime.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:10_000_000
        x += i
    end
    sleep(1)
    x
end

@time @CPUtime add_and_sleep()
elapsed CPU time: 0.000174 seconds
  1.005624 seconds (32 allocations: 1.109 KiB)
50000005000000