<%
threads = table.index.levels[0]
progs = table.index.levels[1]
minvals = {}
for t in threads:
    for var in ('DurationSecs', 'MemoryMB', 'CPUPct'):
        vals = sorted(table.loc[t, :, 'DurationSecs'].reset_index()['min'].tolist())
        minvals[(t,var)] = vals[0]
%>
\begin{table}[ht]
\centering
\begin{tabular}{l${'r|r' * len(threads)}}
\sisetup{detect-weight=true,detect-inline-weight=math}
    % if len(threads) == 1:
    Program & Min & Max \\\\
    \hfill{} & \multicolumn{2}{c}{Execution Time (sec.)} \\\hline
    % else:
    \hfill{} & ${" & ".join("\multicolumn{{2}}{{c}}{{{} Threads}}".format(t) for t in threads)} \\\hline
    Program & \multicolumn{${len(threads)*2}}{c}{Execution Time (Min$|$Max sec.)} \\\hline
    % endif
    % for p in progs:
        ${p}
        % for t in threads:
        <% minval = table.loc[t, p, 'DurationSecs']['min'] %>
        % if minval == minvals[(t, 'DurationSecs')]:
        & \hlcell{${minval}}
        % else:
        & ${minval}
        % endif
        & ${table.loc[t, p, 'DurationSecs']['max']}
        
        % endfor 
        \\\\
    % endfor
    \hline
    
    % if len(threads) == 1:
    \hfill{} & \multicolumn{2}{c}{Memory Usage (MB)} \\\hline
    % else:
    \hfill{} & \multicolumn{${len(threads)*2}}{c}{Memory Usage (Min$|$Max MB)} \\\hline
    % endif
    % for p in progs:
        ${p} &
        % for t in threads:
        <% minval = table.loc[t, p, 'MemoryMB']['min'] %>
        % if minval == minvals[(t, 'MemoryMB')]:
        & \hlcell{${minval}}
        % else:
        & ${minval}
        % endif
        & ${table.loc[t, p, 'MemoryMB']['max']}
        
        % endfor
        \\\\
    % endfor
    \hline
    
    % if len(threads) == 1:
    \hfill{} & \multicolumn{2}{c}{CPU Usage (%)} \\\hline
    % else:
    \hfill{} & \multicolumn{${len(threads)*2}}{c}{CPU Usage (Min$|$Max %)} \\\hline
    % endif
    % for p in progs:
    
        ${p} &
        % for t in threads:
        <% minval = table.loc[t, p, 'CPUPct']['min'] %>
        % if minval == minvals[(t, 'CPUPct')]:
        & \hlcell{${minval}}
        % else:
        & ${minval}
        % endif
        & ${table.loc[t, p, 'CPUPct']['max']}
        
        % endfor
        \\\\
    % endfor
    
\end{tabular}
\caption{\label{tab:${name}}${caption}}
\end{table}
