forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.jl
25 lines (23 loc) · 655 Bytes
/
profile.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# This file is a part of Julia. License is MIT: https://julialang.org/license
function busywait(t, n_tries)
iter = 0
while iter < n_tries && Profile.len_data() == 0
iter += 1
tend = time() + t
while time() < tend end
end
end
Profile.clear()
@profile busywait(1, 20)
let iobuf = IOBuffer()
Profile.print(iobuf, format=:tree, C=true)
str = takebuf_string(iobuf)
@test !isempty(str)
Profile.print(iobuf, format=:flat, C=true)
str = takebuf_string(iobuf)
@test !isempty(str)
Profile.print(iobuf)
Profile.print(iobuf, format=:flat)
Profile.clear()
@test isempty(Profile.fetch())
end