From WikiChip
Module:benchmarks
Documentation for this module may be created at Module:benchmarks/doc
local benchmark = {}
local origArgs
function has_arg(name)
-- The argument can exist and be empty or not exist at all
return string.len(origArgs[name] or '') > 0
end
function arg(name)
return origArgs[name]
end
function single_entry(box, argn)
if has_arg(argn) then
box:tag('div'):attr('style', 'min-width: 250px; display: inline-block;'):wikitext("'''" .. argn .. ":''' " .. arg(argn))
end
end
function benchmark.benchmark(frame)
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
else
origArgs = frame
end
local benchmarkbox = mw.html.create('div')
benchmarkbox
:attr('style', 'background:#f9f9f9; margin: 10px 2px 10px 2px; padding: 5px; border: 1px solid #a7d7f9;')
if not has_arg('type') then
return "* ERROR: '''WRONG <code>type</code> parameter!'''"
end
if arg('type') == 'spec' then
return benchmark.spec(benchmarkbox)
end
return benchmarkbox
end
function benchmark.spec(box)
if has_arg('SPECspeed2017_int_base') or has_arg('SPECspeed2017_int_peak')
or has_arg('SPECspeed2017_fp_base') or has_arg('SPECspeed2017_fp_peak')
or has_arg('SPECrate2017_int_base') or has_arg('SPECrate2017_int_peak')
or has_arg('SPECrate2017_fp_base') or has_arg('SPECrate2017_fp_peak') then
box:wikitext('[[Category:microprocessor models with spec cpu2017 benchmarks]]')
box:tag('span'):attr('style', 'float: right;'):wikitext(
"'''Test:''' [[spec/cpu2017|SPEC CPU2017]]<br>" ..
"'''Tested:''' " .. '[' .. arg('test_link') .. ' ' .. arg('test_timestamp') .. ']'
)
end
box:tag('div'):attr('style', 'vertical-align: middle;')
:wikitext("[[File:benchmarks.svg|64px|link=|left]] '''Vendor:''' " ..
arg('vendor') .. "<br>'''System:''' " .. arg('system'))
b = box:tag('div'):attr('style', 'padding: 10px; margin: 0;')
single_entry(b, 'SPECspeed2017_int_base')
single_entry(b, 'SPECspeed2017_int_peak')
single_entry(b, 'SPECspeed2017_fp_base')
single_entry(b, 'SPECspeed2017_fp_peak')
single_entry(b, 'SPECrate2017_int_base')
single_entry(b, 'SPECrate2017_int_peak')
single_entry(b, 'SPECrate2017_fp_base')
single_entry(b, 'SPECrate2017_fp_peak')
return box
end
return benchmark