-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Base.hash and add profiling script
- Loading branch information
Showing
3 changed files
with
61 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Tokenize | ||
|
||
nt = @timed @eval(collect(Tokenize.tokenize("foo + bar"))) | ||
println("First run took $(nt.time) seconds with $(nt.bytes/1e6) MB allocated") | ||
|
||
srcdir = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "..") | ||
|
||
allfiles = [] | ||
for (root, dirs, files) in walkdir(srcdir, follow_symlinks = true) | ||
for file in files | ||
splitext(file)[2] == ".jl" || continue | ||
push!(allfiles, joinpath(root, file)) | ||
end | ||
end | ||
|
||
# warmup | ||
let time_taken = 0.0, allocated = 0.0 | ||
for file in allfiles | ||
content = IOBuffer(read(file, String)) | ||
nt = @timed collect(Tokenize.tokenize(content, Tokens.RawToken)) | ||
time_taken += nt.time | ||
allocated += nt.bytes | ||
end | ||
end | ||
|
||
# actual run | ||
let time_taken = 0.0, allocated = 0.0 | ||
for file in allfiles | ||
content = IOBuffer(read(file, String)) | ||
nt = @timed collect(Tokenize.tokenize(content, Tokens.RawToken)) | ||
time_taken += nt.time | ||
allocated += nt.bytes | ||
end | ||
println("Tokenized $(length(allfiles)) files in $(time_taken) seconds with $(allocated/1e6) MB allocated") | ||
end | ||
|
||
isempty(ARGS) && exit(0) | ||
|
||
using PProf, Profile | ||
|
||
# warm up profiler | ||
let content = read(first(allfiles), String) | ||
@profile collect(Tokenize.tokenize(content, Tokens.RawToken)) | ||
end | ||
|
||
Profile.clear() | ||
for file in allfiles | ||
content = read(file, String) | ||
@profile collect(Tokenize.tokenize(content, Tokens.RawToken)) | ||
end | ||
pprof() | ||
|
||
println("Press any key to exit...") | ||
readline() |