Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (timeit_debug) #1528

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/src/CodeTiming.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,21 @@ If you are concerned about the performance of your code, a good place to start i
## Timing and benchmarking

Julia has many nice timing tools available. Tools like [@time](https://docs.julialang.org/en/v1/base/base/#Base.@time) and [TimerOutputs](https://github.com/KristofferC/TimerOutputs.jl) can be used to measure the time of specific lines of code. For microbenchmarking, we recommend the [BenchmarkTools](https://github.com/JuliaCI/BenchmarkTools.jl) package. For profiling your code, see the Julia documentation on [profiling](https://docs.julialang.org/en/v1/manual/profile/).

## Using TimerOutputs
```julia
using TimerOutputs
using ITensors
using NDTensors: timer
...

TimerOutputs.enable_debug_timings(ITensors)
@timeit timer "dmrg" energy, _ = dmrg(mpo, mps;
nsweeps=nsweeps,
maxdim=maxdim,
mindim=maxdim,
cutoff=cutoff,
outputlevel=0)
println("Energy = $energy")
println(timer)
```
1 change: 1 addition & 0 deletions src/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export
contract,
# global_variables.jl
# Methods
timeit_debug_enabled,
# Macros
@disable_warn_order,
@reset_warn_order,
Expand Down
8 changes: 8 additions & 0 deletions src/global_variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,11 @@ function disable_contraction_sequence_optimization()
_using_contraction_sequence_optimization[] = false
return nothing
end

#
# Turn debug timer for TimerOutputs on and off
#

function timeit_debug_enabled()
return false
end