From a4e07f30e880ab27c2918f81f136e257475b7729 Mon Sep 17 00:00:00 2001
From: Hans Hagen <pragma@wxs.nl>
Date: Thu, 15 Mar 2018 16:04:31 +0100
Subject: 2018-03-15 15:36:00

---
 .../general/manuals/onandon/onandon-speed-000.tex  | 116 +++++++++++++++++++++
 1 file changed, 116 insertions(+)
 create mode 100644 doc/context/sources/general/manuals/onandon/onandon-speed-000.tex

(limited to 'doc/context/sources/general/manuals/onandon/onandon-speed-000.tex')

diff --git a/doc/context/sources/general/manuals/onandon/onandon-speed-000.tex b/doc/context/sources/general/manuals/onandon/onandon-speed-000.tex
new file mode 100644
index 000000000..f48af866d
--- /dev/null
+++ b/doc/context/sources/general/manuals/onandon/onandon-speed-000.tex
@@ -0,0 +1,116 @@
+% \startenvironment onandon-speed-000
+
+% \dontcomplain
+
+\edef\sapolsky{\ignorespaces\cldloadfile{sapolsky}\removeunwantedspaces}
+
+\startluacode
+
+    function document.ResetSample(title)
+        document.elapsed = {
+            title = title,
+            times = { },
+        }
+    end
+
+    function document.RegisterSample(bodyfont,elapsed)
+        table.insert(document.elapsed.times, {
+            bodyfont = bodyfont,
+            elapsed  = elapsed
+        })
+    end
+
+    function document.SaveSample()
+        if LUATEXENGINE == "luajittex" then
+            table.save(tex.jobname.."-jit.lua",document.elapsed)
+        else
+            table.save(tex.jobname..".lua",document.elapsed)
+        end
+    end
+
+    function document.ShowSample(filename)
+     -- context.typefile(filename..".tex")
+        local elapsed    = table.load(file.nameonly(filename)..".lua")
+        local elapsedjit = table.load(file.nameonly(filename).."-jit.lua")
+        if elapsed and elapsedjit then
+            context.testpage { 6 }
+            context.starttabulate { "|l|l|lp|" }
+            context.HL()
+            context.NC() context.formatted.rlap("\\bf %s",elapsed.title)
+            context.NC()
+            context.NC()
+            context.NC() context.NR()
+            context.HL()
+            local times    = elapsed.times
+            local timesjit = elapsedjit.times
+            for j=1,#times do
+                local t    = times[j]
+                local tjit = timesjit[j]
+                context.NC() context(t.bodyfont)
+                context.NC() context(t.elapsed)
+                context.NC() context(tjit.elapsed)
+                context.NC() context.NR()
+            end
+            context.HL()
+            context.stoptabulate()
+        end
+    end
+
+    function document.SampleTitle(filename)
+        local elapsed = table.load(filename..".lua")
+        if elapsed then
+            context(elapsed.title)
+        end
+    end
+\stopluacode
+
+\appendtoks
+    \ctxlua{document.SaveSample()}%
+\to \everystoptext
+
+\def\SampleCount{1000}
+\def\SampleCount{100}
+
+\unexpanded\def\RegisterSample#1%
+  {\ctxlua{document.RegisterSample("#1","\elapsedtime")}}
+
+\unexpanded\def\ProcessSample#1%
+  {\page
+   \ctxlua{document.ResetSample("#1")}%
+   \resettimer \Sample {modern}      \RegisterSample {modern}
+   \resettimer \Sample {pagella}     \RegisterSample {pagella}
+   \resettimer \Sample {termes}      \RegisterSample {termes}
+   \resettimer \Sample {cambria}     \RegisterSample {cambria}
+   \resettimer \Sample {dejavu}      \RegisterSample {dejavu}
+   \resettimer \Sample {ebgaramond}  \RegisterSample {ebgaramond}
+   \resettimer \Sample {lucidaot}    \RegisterSample {lucidaot}
+   \page }
+
+\unexpanded\def\ProcessBaselineSample#1%
+  {\page
+   \ctxlua{document.ResetSample("#1")}%
+   \resettimer \Sample {baseline} \RegisterSample {baseline}
+   \page }
+
+\unexpanded\def\Sample#1%
+  {\setupbodyfont[#1]}
+
+\unexpanded\def\ShowSample#1%
+  {\ctxlua{document.ShowSample("#1")}}
+
+\unexpanded\def\SampleTitle#1%
+  {\ctxlua{document.SampleTitle("#1.lua")}}
+
+\continueifinputfile{onandon-speed-000.tex}
+
+\starttext
+
+\ProcessSample{bodyfont}
+
+\setbox\scratchbox\vbox{\hsize1pt\tttf\sapolsky} \getnoflines{\htdp\scratchbox}
+
+\writestatus{!!!!!!}{noflines : \the\noflines}
+
+\stoptext
+
+% \stopenvironment
-- 
cgit v1.2.3

