-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
262 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Run benchmark tests in TeX Live | ||
|
||
on: push | ||
|
||
jobs: | ||
run-ubuntu: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: [2022, 2023, 2024] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install TeX Live | ||
uses: teatimeguest/setup-texlive-action@v3 | ||
with: | ||
version: ${{matrix.version}} | ||
package-file: .github/workflows/texlive-package.txt | ||
#packages: codehigh | ||
update-all-packages: true | ||
- name: Run benchmark tests for codehigh package | ||
run: | | ||
cd benchmark | ||
texlua benchmark.lua ${{matrix.version}} | ||
- name: Store benchmark result | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: Codehigh Benchmark in TeX Live ${{matrix.version}} | ||
tool: "customSmallerIsBetter" | ||
output-file-path: benchmarks/output-${{matrix.version}}.txt | ||
benchmark-data-dir-path: benchmark/${{matrix.version}} | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
auto-push: true |
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
File renamed without changes.
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,170 @@ | ||
--- codehigh benchmark script | ||
|
||
local function fileRead(input) | ||
local f = io.open(input, "rb") | ||
local text | ||
if f then -- file exists and is readable | ||
text = f:read("*all") | ||
f:close() | ||
return text | ||
end | ||
-- return nil if file doesn't exists or isn't readable | ||
end | ||
|
||
local function fileWrite(text, output) | ||
-- using "wb" keeps unix eol characters | ||
f = io.open(output, "wb") | ||
f:write(text) | ||
f:close() | ||
end | ||
|
||
local function fileNormalize(fname) | ||
return string.gsub(fname, "/", "\\") | ||
end | ||
|
||
local function fileCopy(from, to) | ||
if os.type == "windows" then | ||
from = fileNormalize(from) | ||
to = fileNormalize(to) | ||
os.execute("copy /y" .. " " .. from .. " " .. to) | ||
else | ||
os.execute("cp -f" .. " " .. from .. " " .. to) | ||
end | ||
end | ||
|
||
local function fileDelete(fname) | ||
if os.type == "windows" then | ||
fname = fileNormalize(fname) | ||
os.execute("del" .. " " .. fname) | ||
else | ||
os.execute("rm" .. " " .. fname) | ||
end | ||
end | ||
|
||
local warmupruns = 1 | ||
local benchruns = 4 | ||
local programs = {"pdflatex", "xelatex", "lualatex"} | ||
local optn = "--interaction=nonstopmode" | ||
local isquiet = true | ||
|
||
local function makeCmdString(prog, name) | ||
local str = prog .. " " .. optn .. " " .. name .. ".tex" | ||
if isquiet == true then | ||
if os.type == "windows" then | ||
str = str .. " >NUL" | ||
else | ||
str = str .. " >/dev/null" | ||
end | ||
end | ||
print(str) | ||
return str | ||
end | ||
|
||
local function bmTestOne(tbl, prog, name) | ||
for i = 1, warmupruns do | ||
os.execute(makeCmdString(prog, name)) | ||
end | ||
for i = 1, benchruns do | ||
os.execute(makeCmdString(prog, name)) | ||
local text = fileRead(name .. ".log") | ||
local t = string.match(text, "> \\g_benchmark_time_fp =([%d]+%.[%d]+)%.") | ||
if t == nil then | ||
error("failed to get benchmark time for " .. prog) | ||
else | ||
--print(prog .. " used time " .. i, t) | ||
table.insert(tbl[prog], tonumber(t)) | ||
end | ||
end | ||
end | ||
|
||
local function bmTestSome(tbl, name) | ||
for _, p in ipairs(programs) do | ||
bmTestOne(tbl, p, name) | ||
end | ||
end | ||
|
||
local function initTimeTable(tbl) | ||
for _, p in ipairs(programs) do | ||
tbl[p] = {} | ||
end | ||
end | ||
|
||
local oldtime = {} | ||
local newtime = {} | ||
local tblold = {} | ||
local tblnew = {} | ||
local tblratio = {} | ||
local isoldfirst = true | ||
|
||
local function bmRun(name) | ||
initTimeTable(oldtime) | ||
initTimeTable(newtime) | ||
if isoldfirst then | ||
fileDelete("codehigh.sty") | ||
fileDelete("codehigh.lua") | ||
bmTestSome(oldtime, name) | ||
fileCopy("../codehigh.sty", "codehigh.sty") | ||
fileCopy("../codehigh.lua", "codehigh.lua") | ||
bmTestSome(newtime, name) | ||
else | ||
fileCopy("../codehigh.sty", "codehigh.sty") | ||
fileCopy("../codehigh.lua", "codehigh.lua") | ||
bmTestSome(newtime, name) | ||
fileDelete("codehigh.sty") | ||
fileDelete("codehigh.lua") | ||
bmTestSome(oldtime, name) | ||
end | ||
for _, p in ipairs(programs) do | ||
local oldt, newt = 0, 0 | ||
for i = 1, benchruns do | ||
print(p .. " used time " .. i, "old = " .. oldtime[p][i], "new = " .. newtime[p][i]) | ||
oldt = oldt + oldtime[p][i] | ||
newt = newt + newtime[p][i] | ||
end | ||
oldt = oldt / benchruns | ||
newt = newt / benchruns | ||
ratio = newt / oldt | ||
print(p .. " average time " , "old = " .. oldt, "new = " .. newt, "ratio = " .. ratio) | ||
tblold[p] = oldt | ||
tblnew[p] = newt | ||
tblratio[p] = ratio | ||
end | ||
end | ||
|
||
local outtempl = [[{ | ||
"name": "compile codehigh with {{program}}", | ||
"unit": "ratio", | ||
"value": {{ratio}}, | ||
"extra": "current time : previous time = {{newtime}} : {{oldtime}}" | ||
}]] | ||
|
||
local function bmFillTemplate(prog, ratio, newt, oldt) | ||
local str = outtempl | ||
str = str:gsub("{{program}}", prog, 1) | ||
:gsub("{{ratio}}", ratio, 1) | ||
:gsub("{{newtime}}", newt, 1) | ||
:gsub("{{oldtime}}", oldt, 1) | ||
--print(str) | ||
return str | ||
end | ||
|
||
local function bmOutput(tlver) | ||
local out = {} | ||
for _, p in ipairs(programs) do | ||
table.insert(out, bmFillTemplate(p, tblratio[p], tblnew[p], tblold[p])) | ||
end | ||
local text = "[\n " .. table.concat(out, ",\n ") .. "\n]" | ||
--print(text) | ||
fileWrite(text, "output-" .. tlver .. ".txt") | ||
end | ||
|
||
local function main(name) | ||
if arg[1] == nil then | ||
error("missing texlive version") | ||
else | ||
bmRun(name) | ||
bmOutput(arg[1]) | ||
end | ||
end | ||
|
||
main("tblrbenchmark") |
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,58 @@ | ||
\documentclass{article} | ||
\usepackage[a4paper,margin=2cm]{geometry} | ||
\usepackage{codehigh} | ||
\usepackage{hyperref} | ||
\usepackage{l3benchmark} | ||
\ExplSyntaxOn | ||
\int_set:Nn \l_iow_line_count_int {140} % default to 78 | ||
\let \replicate = \prg_replicate:nn | ||
\AtBeginDocument{\benchmark_tic:} | ||
\AtEndDocument{ | ||
\benchmark_toc: | ||
\fp_log:n \g_benchmark_time_fp | ||
} | ||
\ExplSyntaxOff | ||
\NewDocumentCommand\mylipsum{O{1}}{% | ||
\replicate{#1}{The quick brown fox jumps over the lazy dog. }% | ||
} | ||
\begin{document} | ||
|
||
\mylipsum[32] | ||
|
||
\begin{codehigh} | ||
% -*- coding: utf-8 -*- | ||
\documentclass{article} | ||
\usepackage[a4paper,margin=2cm]{geometry} | ||
\usepackage{codehigh} | ||
\usepackage{hyperref} | ||
\newcommand*{\myversion}{2021C} | ||
\newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)} | ||
\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi} | ||
\setlength{\abc}{1} | ||
\begin{document} | ||
% some comment | ||
\section{Section Name} | ||
\subsection*{Suction Name} | ||
Math $a+b$. | ||
\end{document} | ||
\end{codehigh} | ||
|
||
\mylipsum[32] | ||
|
||
\begin{demohigh}[language=latex/table] | ||
\begin{tabular}{lccr} | ||
\hline | ||
Alpha & Beta & Gamma & Delta \\ | ||
\hline | ||
Epsilon & Zeta & Eta & Theta \\ | ||
\hline | ||
Iota & Kappa & Lambda & Mu \\ | ||
\hline | ||
\end{tabular} | ||
\end{demohigh} | ||
|
||
\mylipsum[32] | ||
|
||
\dochighinput[language=latex/latex3]{codehigh.sty} | ||
|
||
\end{document} |