Skip to content

Commit

Permalink
Merge pull request #10 from schmrlng/Project.toml
Browse files Browse the repository at this point in the history
Replace REQUIRE with Project.toml
  • Loading branch information
schmrlng authored May 19, 2019
2 parents 738a27a + 01cd29b commit 4285f1a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
14 changes: 8 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
## Documentation: http://docs.travis-ci.com/user/languages/julia/
language: julia
notifications:
email: false
os:
- linux
- osx
julia:
- 0.6
- 0.7
- 1.0
- 1.1
- nightly
#script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'Pkg.init(); Pkg.clone(pwd()); Pkg.test("CPUTime")'
notifications:
email: false
13 changes: 13 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = "CPUTime"
uuid = "a9c8d775-2e2e-55fc-8582-045d282d599e"
authors = ["Ed Schmerling <[email protected]>"]
version = "1.0.0"

[compat]
julia = "≥ 0.7.0"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
2 changes: 0 additions & 2 deletions REQUIRE

This file was deleted.

16 changes: 7 additions & 9 deletions src/CPUTime.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module CPUTime

using Compat

export
CPUtime_us,
CPUtic,
Expand All @@ -11,14 +9,14 @@ export
@CPUelapsed

function CPUtime_us()
@compat rusage = Libc.malloc(4*sizeof(Clong) + 14*sizeof(UInt64)) # sizeof(uv_rusage_t); this is different from sizeof(rusage)
rusage = Libc.malloc(4*sizeof(Clong) + 14*sizeof(UInt64)) # sizeof(uv_rusage_t); this is different from sizeof(rusage)
ccall(:uv_getrusage, Cint, (Ptr{Nothing},), rusage)
@compat utime = UInt64(1000000)*unsafe_load(convert(Ptr{Clong}, rusage + 0*sizeof(Clong))) + # user CPU time
unsafe_load(convert(Ptr{Clong}, rusage + 1*sizeof(Clong)))
@compat stime = UInt64(1000000)*unsafe_load(convert(Ptr{Clong}, rusage + 2*sizeof(Clong))) + # system CPU time
unsafe_load(convert(Ptr{Clong}, rusage + 3*sizeof(Clong)))
utime = UInt64(1000000)*unsafe_load(convert(Ptr{Clong}, rusage + 0*sizeof(Clong))) + # user CPU time
unsafe_load(convert(Ptr{Clong}, rusage + 1*sizeof(Clong)))
stime = UInt64(1000000)*unsafe_load(convert(Ptr{Clong}, rusage + 2*sizeof(Clong))) + # system CPU time
unsafe_load(convert(Ptr{Clong}, rusage + 3*sizeof(Clong)))
ttime = utime + stime # total CPU time
@compat Libc.free(rusage)
Libc.free(rusage)
return ttime
end

Expand All @@ -34,7 +32,7 @@ function CPUtoq()
if timers === ()
error("CPUtoc() without CPUtic()")
end
@compat t0 = timers[1]::UInt64
t0 = timers[1]::UInt64
task_local_storage(:CPUTIMERS, timers[2])
(t1-t0)/1e6
end
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using CPUTime
using Compat.Test
using Test

function add_and_sleep()
x = 0
for i in 1:1e7
for i in 1:10_000_000
x += i
end
sleep(1)
Expand All @@ -18,4 +18,4 @@ end

time_difference() # compilation overhead should not affect results, but just in case
time_diff = time_difference()
eval(Meta.parse("@test abs($time_diff - 1.0) <= .01"))
eval(Meta.parse("@test abs($time_diff - 1.0) <= .1"))

2 comments on commit 4285f1a

@schmrlng
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

Release notes:

Switch to Project.toml for package registration.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/872

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" 4285f1abb29d3575da241c48bb96e34f9b622905
git push origin v1.0.0

Please sign in to comment.