From WikiChip
Difference between revisions of "Module:benchmarks"
(24 intermediate revisions by 3 users not shown) | |||
Line 8: | Line 8: | ||
function arg(name) | function arg(name) | ||
− | return origArgs[name] | + | return origArgs[name] or '' |
end | end | ||
Line 19: | Line 19: | ||
function benchmark.benchmark(frame) | function benchmark.benchmark(frame) | ||
+ | benchmark.frame = frame | ||
if frame == mw.getCurrentFrame() then | if frame == mw.getCurrentFrame() then | ||
origArgs = frame:getParent().args | origArgs = frame:getParent().args | ||
Line 34: | Line 35: | ||
end | end | ||
− | if arg('type') == ' | + | if arg('type') == 'spec_cpu2017' then |
− | return benchmark. | + | return benchmark.spec_cpu2017(benchmarkbox) |
end | end | ||
Line 42: | Line 43: | ||
− | function benchmark. | + | function benchmark.spec_cpu2017(box) |
− | + | 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') .. ']<br>' .. | ||
+ | "'''Chips:''' " .. arg('chip_count') .. ", " .. | ||
+ | "'''Cores:''' " .. arg('core_count') .. ", " .. | ||
+ | (has_arg('copies_count') == true | ||
+ | and ("'''Copies:''' " .. arg('copies_count')) | ||
+ | or ("'''Threads:''' " .. arg('thread_count'))) | ||
+ | ) | ||
− | + | 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: 3px; margin: 0;') | |
− | + | ||
− | + | local suboject = "|benchmark type=SPEC CPU2017" | |
− | + | ||
− | + | suboject = suboject .. "\n|full page name=" .. benchmark.frame:preprocess('{{FULLPAGENAME}}') | |
− | + | ||
− | + | suboject = suboject .. "\n|timestamp=" .. arg('test_timestamp') | |
− | + | suboject = suboject .. "\n|spec/url=" .. arg('test_link') | |
− | + | ||
− | + | suboject = suboject .. "\n|spec/vendor=" .. arg('vendor') | |
− | + | suboject = suboject .. "\n|spec/system=" .. arg('system') | |
− | + | ||
− | + | suboject = suboject .. "\n|spec/chip count=" .. arg('chip_count') | |
− | + | suboject = suboject .. "\n|spec/core count=" .. arg('core_count') | |
− | + | suboject = (has_arg('copies_count') == true | |
− | + | and (suboject .. "\n|spec/copies count=" .. arg('copies_count')) | |
− | + | or (suboject .. "\n|spec/thread count=" .. arg('thread_count'))) | |
+ | |||
+ | single_entry(b, 'SPECspeed2017_int_base') | ||
+ | suboject = suboject .. "\n|spec/specspeed2017_int_base=" .. arg('SPECspeed2017_int_base') | ||
+ | single_entry(b, 'SPECspeed2017_int_peak') | ||
+ | suboject = suboject .. "\n|spec/specspeed2017_int_peak=" .. arg('SPECspeed2017_int_peak') | ||
+ | single_entry(b, 'SPECspeed2017_fp_base') | ||
+ | suboject = suboject .. "\n|spec/specspeed2017_fp_base=" .. arg('SPECspeed2017_fp_base') | ||
+ | single_entry(b, 'SPECspeed2017_fp_peak') | ||
+ | suboject = suboject .. "\n|spec/specspeed2017_fp_peak=" .. arg('SPECspeed2017_fp_peak') | ||
+ | single_entry(b, 'SPECrate2017_int_base') | ||
+ | suboject = suboject .. "\n|spec/specrate2017_int_base=" .. arg('SPECrate2017_int_base') | ||
+ | single_entry(b, 'SPECrate2017_int_peak') | ||
+ | suboject = suboject .. "\n|spec/specrate2017_int_peak=" .. arg('SPECrate2017_int_peak') | ||
+ | single_entry(b, 'SPECrate2017_fp_base') | ||
+ | suboject = suboject .. "\n|spec/specrate2017_fp_base=" .. arg('SPECrate2017_fp_base') | ||
+ | single_entry(b, 'SPECrate2017_fp_peak') | ||
+ | suboject = suboject .. "\n|spec/specrate2017_fp_peak=" .. arg('SPECrate2017_fp_peak') | ||
+ | |||
+ | |||
+ | benchmark.frame:preprocess("{{#subobject:\n" .. suboject .. "\n}}") | ||
return box | return box |
Latest revision as of 00:52, 27 November 2017
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] or ''
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)
benchmark.frame = 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_cpu2017' then
return benchmark.spec_cpu2017(benchmarkbox)
end
return benchmarkbox
end
function benchmark.spec_cpu2017(box)
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') .. ']<br>' ..
"'''Chips:''' " .. arg('chip_count') .. ", " ..
"'''Cores:''' " .. arg('core_count') .. ", " ..
(has_arg('copies_count') == true
and ("'''Copies:''' " .. arg('copies_count'))
or ("'''Threads:''' " .. arg('thread_count')))
)
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: 3px; margin: 0;')
local suboject = "|benchmark type=SPEC CPU2017"
suboject = suboject .. "\n|full page name=" .. benchmark.frame:preprocess('{{FULLPAGENAME}}')
suboject = suboject .. "\n|timestamp=" .. arg('test_timestamp')
suboject = suboject .. "\n|spec/url=" .. arg('test_link')
suboject = suboject .. "\n|spec/vendor=" .. arg('vendor')
suboject = suboject .. "\n|spec/system=" .. arg('system')
suboject = suboject .. "\n|spec/chip count=" .. arg('chip_count')
suboject = suboject .. "\n|spec/core count=" .. arg('core_count')
suboject = (has_arg('copies_count') == true
and (suboject .. "\n|spec/copies count=" .. arg('copies_count'))
or (suboject .. "\n|spec/thread count=" .. arg('thread_count')))
single_entry(b, 'SPECspeed2017_int_base')
suboject = suboject .. "\n|spec/specspeed2017_int_base=" .. arg('SPECspeed2017_int_base')
single_entry(b, 'SPECspeed2017_int_peak')
suboject = suboject .. "\n|spec/specspeed2017_int_peak=" .. arg('SPECspeed2017_int_peak')
single_entry(b, 'SPECspeed2017_fp_base')
suboject = suboject .. "\n|spec/specspeed2017_fp_base=" .. arg('SPECspeed2017_fp_base')
single_entry(b, 'SPECspeed2017_fp_peak')
suboject = suboject .. "\n|spec/specspeed2017_fp_peak=" .. arg('SPECspeed2017_fp_peak')
single_entry(b, 'SPECrate2017_int_base')
suboject = suboject .. "\n|spec/specrate2017_int_base=" .. arg('SPECrate2017_int_base')
single_entry(b, 'SPECrate2017_int_peak')
suboject = suboject .. "\n|spec/specrate2017_int_peak=" .. arg('SPECrate2017_int_peak')
single_entry(b, 'SPECrate2017_fp_base')
suboject = suboject .. "\n|spec/specrate2017_fp_base=" .. arg('SPECrate2017_fp_base')
single_entry(b, 'SPECrate2017_fp_peak')
suboject = suboject .. "\n|spec/specrate2017_fp_peak=" .. arg('SPECrate2017_fp_peak')
benchmark.frame:preprocess("{{#subobject:\n" .. suboject .. "\n}}")
return box
end
return benchmark