File tree Expand file tree Collapse file tree 2 files changed +20
-13
lines changed
Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ using Memoization
3535using NamedTupleTools: select, delete
3636using PDMats
3737using Pkg
38+ using Preferences
3839using Printf
3940using ProgressMeter
4041using QuadGK
Original file line number Diff line number Diff line change @@ -375,6 +375,8 @@ expnorm(x) = exp.(x .- maximum(x))
375375# MacroTool's is broken https://github.com/FluxML/MacroTools.jl/issues/154
376376_isdef (ex) = @capture (ex, function f_ (arg__) body_ end )
377377
378+ const _⌛_enabled = @load_preference (" ⌛_enabled" , default= true )
379+
378380"""
379381
380382 @⌛ [label] code ...
@@ -398,21 +400,25 @@ macro ⌛(args...)
398400 else
399401 label, ex = esc (args[1 ]), args[2 ]
400402 end
401- source_str = last (splitpath (string (__source__. file)))* " :" * string (__source__. line)
402- if _isdef (ex)
403- sdef = splitdef (ex)
404- if isnothing (label)
405- label = " $(string (sdef[:name ])) (…) ($source_str )"
406- end
407- sdef[:body ] = quote
408- CMBLensing. @timeit $ label $ (sdef[:body ])
403+ if _⌛_enabled
404+ source_str = last (splitpath (string (__source__. file)))* " :" * string (__source__. line)
405+ if _isdef (ex)
406+ sdef = splitdef (ex)
407+ if isnothing (label)
408+ label = " $(string (sdef[:name ])) (…) ($source_str )"
409+ end
410+ sdef[:body ] = quote
411+ CMBLensing. @timeit $ label $ (sdef[:body ])
412+ end
413+ esc (combinedef (sdef))
414+ else
415+ if isnothing (label)
416+ label = " $(Base. _truncate_at_width_or_chars (string (prewalk (rmlines,ex)),26 )) ($source_str )"
417+ end
418+ :(@timeit $ label $ (esc (ex)))
409419 end
410- esc (combinedef (sdef))
411420 else
412- if isnothing (label)
413- label = " $(Base. _truncate_at_width_or_chars (string (prewalk (rmlines,ex)),26 )) ($source_str )"
414- end
415- :(@timeit $ label $ (esc (ex)))
421+ esc (ex)
416422 end
417423end
418424
You can’t perform that action at this time.
0 commit comments