Skip to content

Commit

Permalink
benchmarking frontmatter eval
Browse files Browse the repository at this point in the history
  • Loading branch information
tlienart committed Aug 2, 2023
1 parent 4bdade6 commit 444a237
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/logging/timer.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#
# very coarse timings logger to allow digging into what is most expensive.
# will probably either be completely removed or replaced by a stand-alone module
#

const TIMER = Vector{NamedTuple{(:depth,:label,:duration), Tuple{Int64,String,Float64}}}()
const TIMERN = Ref(0)

Expand Down
2 changes: 1 addition & 1 deletion src/process/config_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ end
# ------------- #

"""""
process_utils(utils, gc)
process_utils(gc, utils)
Process a utils string into a given global context object. This is always called
in a "fresh" GC context (i.e. one where no code has been executed yet).
Expand Down
29 changes: 28 additions & 1 deletion test/_x_perf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using BenchmarkTools

# ====================================
# Time to create a DefaultLocalContext
# as of 29/7/2023 it's around 0.33ms.
# as of 29/7/2023 it's around 0.33ms << 1ms
begin
u = raw"""
import Literate
Expand Down Expand Up @@ -50,5 +50,32 @@ begin
"""

gc = X.DefaultGlobalContext()
X.process_utils(gc, u)
@btime X.DefaultLocalContext($gc; rpath=randstring(5));
end


# =================================================================
# Time to create a DefaultLocalContext and evaluate a front matter
# with or without a date doesn't change much, it takes around 1.8-2.0ms.
# eval of hfun fill takes negligible time on top of that
begin
u = raw"""
@reexport using Dates
"""
gc = X.DefaultGlobalContext()
X.process_utils(gc, u)
function foo(_gc)
lc = X.DefaultLocalContext(_gc; rpath=randstring(5))
c = """
+++
pub = Date(2023, 8, 15)
title = "hello"
+++
ABC {{pub}}
"""
html(c, lc)
end
@btime foo($gc);
end

0 comments on commit 444a237

Please sign in to comment.