Skip to content

Commit

Permalink
move Profile to stdlib (#24355)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Oct 27, 2017
1 parent c4558e3 commit d4b80e3
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 57 deletions.
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,9 @@ export conv, conv2, deconv, filt, filt!, xcorr

@deprecate_binding Mmap nothing true ", run `using Mmap` instead"

@deprecate_binding Profile nothing true ", run `using Profile` instead"
@eval @deprecate_moved $(Symbol("@profile")) "Profile" true true

# PR #21709
@deprecate cov(x::AbstractVector, corrected::Bool) cov(x, corrected=corrected)
@deprecate cov(x::AbstractMatrix, vardim::Int, corrected::Bool) cov(x, vardim, corrected=corrected)
Expand Down
2 changes: 0 additions & 2 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export
Pkg,
LibGit2,
StackTraces,
Profile,
Dates,
Sys,
Libc,
Expand Down Expand Up @@ -1211,7 +1210,6 @@ export
@timev,
@elapsed,
@allocated,
@profile,

# reflection
@which,
Expand Down
4 changes: 0 additions & 4 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,6 @@ include("libgit2/libgit2.jl")
# package manager
include("pkg/pkg.jl")

# profiler
include("profile.jl")
using .Profile

# dates
include("dates/Dates.jl")
import .Dates: Date, DateTime, DateFormat, @dateformat_str, now
Expand Down
6 changes: 4 additions & 2 deletions doc/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ if Sys.iswindows()
cp_q("../stdlib/Test/docs/src/index.md", "src/stdlib/test.md")
cp_q("../stdlib/Mmap/docs/src/index.md", "src/stdlib/mmap.md")
cp_q("../stdlib/SharedArrays/docs/src/index.md", "src/stdlib/sharedarrays.md")
cp_q("../stdlib/Profile/docs/src/index.md", "src/stdlib/profile.md")
else
symlink_q("../../../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md")
symlink_q("../../../stdlib/Test/docs/src/index.md", "src/stdlib/test.md")
symlink_q("../../../stdlib/Mmap/docs/src/index.md", "src/stdlib/mmap.md")
symlink_q("../../../stdlib/SharedArrays/docs/src/index.md", "src/stdlib/sharedarrays.md")
symlink_q("../../../stdlib/Profile/docs/src/index.md", "src/stdlib/profile.md")
end

const PAGES = [
Expand Down Expand Up @@ -133,11 +135,11 @@ const PAGES = [
],
]

using DelimitedFiles, Test, Mmap, SharedArrays
using DelimitedFiles, Test, Mmap, SharedArrays, Profile

makedocs(
build = joinpath(pwd(), "_build/html/en"),
modules = [Base, Core, BuildSysImg, DelimitedFiles, Test, Mmap, SharedArrays],
modules = [Base, Core, BuildSysImg, DelimitedFiles, Test, Mmap, SharedArrays, Profile],
clean = false,
doctest = "doctest" in ARGS,
linkcheck = "linkcheck" in ARGS,
Expand Down
2 changes: 2 additions & 0 deletions doc/src/manual/profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ julia> myfunc() # run once to force compilation
Now we're ready to profile this function:

```julia-repl
julia> using Profile
julia> @profile myfunc()
```

Expand Down
1 change: 1 addition & 0 deletions doc/src/stdlib/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ delimitedfiles.md
test.md
mmap.md
sharedarrays.md
profile.md
3 changes: 0 additions & 3 deletions doc/src/stdlib/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Functions are grouped by topic below.

Some general notes:

* Except for functions in built-in modules (`Pkg`, `Collections`, `Test`
and `Profile`), all functions documented here are directly available for use in programs.
* To use module functions, use `import Module` to import the module, and `Module.fn(x)` to use the
functions.
* Alternatively, `using Module` will import all exported `Module` functions into the current namespace.
Expand Down Expand Up @@ -103,7 +101,6 @@ Base.LinAlg
Base.Markdown
Base.Meta
Base.Pkg
Base.Profile
Base.Serializer
Base.SparseArrays
Base.StackTraces
Expand Down
17 changes: 0 additions & 17 deletions doc/src/stdlib/profile.md

This file was deleted.

17 changes: 17 additions & 0 deletions stdlib/Profile/docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# [Profiling](@id lib-profiling)

```@docs
Profile.@profile
```

The methods in `Profile` are not exported and need to be called e.g. as `Profile.print()`.

```@docs
Profile.clear
Profile.print
Profile.init
Profile.fetch
Profile.retrieve
Profile.callers
Profile.clear_malloc_data
```
File renamed without changes.
15 changes: 15 additions & 0 deletions test/profile.jl → stdlib/Profile/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Test, Profile

function busywait(t, n_tries)
iter = 0
while iter < n_tries && Profile.len_data() == 0
Expand Down Expand Up @@ -43,3 +45,16 @@ let iobuf = IOBuffer()
Profile.clear()
@test isempty(Profile.fetch())
end

# issue #13229
module I13229
using Test, Profile
global z = 0
@timed @profile for i = 1:5
function f(x)
return x + i
end
global z = f(i)
end
@test z == 10
end
12 changes: 1 addition & 11 deletions test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,14 @@ function choosetests(choices = [])
"combinatorics", "sysinfo", "env", "rounding", "ranges", "mod2pi",
"euler", "show", "lineedit", "replcompletions", "repl",
"replutil", "sets", "goto", "llvmcall", "llvmcall2", "grisu",
"nullable", "meta", "stacktraces", "profile", "libgit2", "docs",
"nullable", "meta", "stacktraces", "libgit2", "docs",
"markdown", "base64", "serialize", "misc", "threads",
"enums", "cmdlineargs", "i18n", "workspace", "libdl", "int",
"checked", "bitset", "floatfuncs", "compile", "distributed", "inline",
"boundscheck", "error", "ambiguous", "cartesian", "asmvariant", "osutils",
"channels", "iostream", "specificity", "codegen", "codevalidation",
"reinterpretarray"
]
profile_skipped = false
if startswith(string(Sys.ARCH), "arm")
# Remove profile from default tests on ARM since it currently segfaults
# Allow explicitly adding it for testing
filter!(x -> (x != "profile"), testnames)
profile_skipped = true
end

if isdir(joinpath(JULIA_HOME, Base.DOCDIR, "examples"))
push!(testnames, "examples")
Expand All @@ -83,9 +76,6 @@ function choosetests(choices = [])

if tests == ["all"] || isempty(tests)
tests = testnames
if profile_skipped
warn("profile test skipped")
end
end

datestests = ["dates/accessors", "dates/adjusters", "dates/query",
Expand Down
17 changes: 0 additions & 17 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3861,23 +3861,6 @@ let grphtest = ((1, [2]),)
end
end

# issue #13229
module I13229
using Test
if !startswith(string(Sys.ARCH), "arm")
global z = 0
@timed @profile for i = 1:5
function f(x)
return x + i
end
global z = f(i)
end
@test z == 10
else
warn("@profile test skipped")
end
end

# issue #15186
let ex = quote
$(if true; :(test); end)
Expand Down
1 change: 1 addition & 0 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ end
# Simple tests for apropos:
@test contains(sprint(apropos, "pearson"), "cor")
@test contains(sprint(apropos, r"ind(exes|ices)"), "eachindex")
using Profile
@test contains(sprint(apropos, "print"), "Profile.print")

# Issue #13068.
Expand Down
9 changes: 8 additions & 1 deletion test/stdlib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@
# test default packages

cd(joinpath(JULIA_HOME,"..","share","julia","site","v$(VERSION.major).$(VERSION.minor)")) do
Pkg.Entry.test(convert(Vector{AbstractString}, readdir()))
pkgs = readdir()
if startswith(string(Sys.ARCH), "arm")
# Remove profile from default tests on ARM since it currently segfaults
# Allow explicitly adding it for testing
warn("Skipping Profile tests")
filter!(x -> (x != "Profile"), pkgs)
end
Pkg.Entry.test(convert(Vector{AbstractString}, pkgs))
end

0 comments on commit d4b80e3

Please sign in to comment.