ug4
|
Functions | |
function util | adjuststring (str, len, type) |
function util | fill (N, c) |
function util | flattenTable (tab, name, resTable) |
function util | getStats (stats, bHeader, seperator, bStats, seperator2) |
function util | printFormattedTable (tab, bNumbers, type, header) |
function util | printFormattedTableSideways (tab, bNumbers, header) |
function util | printStats (stats) |
function util | statsUtilGetHeader (header, tab) |
function util | StringTableFromTable (tab, header, s) |
function util | writeFileStats (stats, filename, seperator) |
This file and the comments are intended to make your life easier when you want to do several runs of a script and you need to evaluate data from the runs, like compare solution times for different number of refinements. First you need to know, what statistics you want to output and compare. Imagine you want to run laplace.lua for several different numRefs or even num procs, and results should be saved in a file "stats.txt", so that you can use in a spreadsheet. The stats format is as follows: it is an array, consisting of entries {description, content} So we need to add to our laplace.lua file the following lines:
after 2 runs, the file stats.txt looks as follows
procs numRefs steps SVN Revision 4 8 6 4459M 16 9 6 4459M
Note that a heading "procs numRefs..." is added to the file if it is empty. All items are seperated by default by " \t", but you can choose different seperators. You can copy and paste the data in most spreadsheet applications like OpenOffice Calc, Excel and Apple Numbers. If you wish a brief table result description of the current task, you can use
which prints
procs: 4 numRefs: 16 steps: 6 SVN Revision: 4459M to the console
For boolean values, use tostring(bExternalCoarsening)
-> "true" / "false". You can seperate your runs by date with the following example bash script:
and in you lua-file, you could use util.writeFileStats(stats, util.GetParam("-outdir", "").."stats.txt")
. Instead of defining -logtofile from the shell, you could also make something like GetLogAssistant():enable_file_output(true, util.GetParam("-outdir". "").."check_numRefs"..numRefs.."_procs"..procs..".txt")
function util adjuststring | ( | str | , |
len | , | ||
type | |||
) |
util.adjuststring returns a string with whitespace left and right so that total string length is len
str | string used |
len | total length of resulting string |
type | padding type: "l" = string is on left, "c" = centered, "r" = right. default "l" |
location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / stats_util.lua :99-111
function util fill | ( | N | , |
c | |||
) |
util.fill returns a string consisting of N times the character c
N | number of times c is to be repeated |
c | character to repeat (if omitted, " ") |
location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / stats_util.lua :84-91
Referenced by ug::SparseMatrix< TValueType >::clear_retain_structure(), ug::CreatePlane(), and ug::VecCopy().
function util flattenTable | ( | tab | , |
name | , | ||
resTable | |||
) |
inserts the table tab into resTable in a "flat" way that means, subtables are getting indices so that the resulting table has no subtables example: tab = {a=2, b="hi", c={word=3, nose=4} } res = {} flattenTable(tab, "tab", res) res = { {"tab.a", 2}, {"tab.b", "hi"}, {"tab.c.word", 3}, {"tab.c.nose", 4} } especially usefull for util.writeFileStats note: syntax {name, value} used instead of name=value because this way the order is stable
location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / stats_util.lua :361-374
function util getStats | ( | stats | , |
bHeader | , | ||
seperator | , | ||
bStats | , | ||
seperator2 | |||
) |
util.getStats internal method
location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / stats_util.lua :39-54
References ug::detail::local(), and print().
function util printFormattedTable | ( | tab | , |
bNumbers | , | ||
type | , | ||
header | |||
) |
util.printFormattedTable prints stats to the console
tab | table in the form t={{["colA" |
bNumbers | if true, print a colum with the key of the table (default false) |
type | type of column padding ("r", "l" or "c", default "l") |
header | colums to be printed, like {"colA", "colB"}. if nil, all. location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / stats_util.lua :170-231 |
function util printFormattedTableSideways | ( | tab | , |
bNumbers | , | ||
header | |||
) |
util.printFormattedTableSideways prints stats to the console, sideways
tab | table in the form t={{["colA" |
type | type of row padding ("r", "l" or "c", default "l") |
bNumbers | if true, print a colum with the number of the table (default false) |
header | colums to be printed, like {"colA", "colB"}, if nil: all |
location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / stats_util.lua :254-304
function util printStats | ( | stats | ) |
util.printStats prints stats to the console
stats | location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / stats_util.lua :116-125 |
function util statsUtilGetHeader | ( | header | , |
tab | |||
) |
location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / stats_util.lua :128-142
function util StringTableFromTable | ( | tab | , |
header | , | ||
s | |||
) |
location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / stats_util.lua :307-341
function util writeFileStats | ( | stats | , |
filename | , | ||
seperator | |||
) |
util.writeFileStats writes stats to a file
stats | |
filename | |
seperator | (default " \t") |
location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / stats_util.lua :62-77