heinrichmartin <
martin....@frequentis.com> writes:
> On Tuesday, September 17, 2019 at 12:28:05 PM UTC+2, Cecil Westerhof wrote:
>> set totalCPU [expr {${totalCPU} + ${CPUUsage}}]
>
> incr totalCPU ${CPUUsage}
CPUUsage is a float, so incr would not work.
>> if {${command} == "*"} {
>> set addLine True
>> } elseif {[regexp "${command}" ${thisCommand}]} {
>
> I'd not make "*" special when a regexp is expected: The empty regexp
> matches everything. If you must support "*", then
Good point: changed.
> if {[regexp ...]} {# doit}
That does not work. When the regexp is empty (in the new situation) I
do not print the commands, but only calculate the total. Otherwise I
print matching lines.
> No need for building a string "${command}". I guess the bytecode
> compiler optimizes it, but just ${command} is enough.
Changed.
> I'd rename variable command to commandRE or commandFilter or
Good point.
> Also, you probably know that you can omit the braces for your
> variable names, but either style is fine.
I know, but I prefer to use them for variable names that are longer as
three characters.
It has become:
if {${commandRE} == ""} {
set addLine True
} elseif {[regexp ${commandRE} ${command}]} {
puts [format ${formatStr} ${CPUUsage} ${command}]
set addLine True
}
if {${addLine}} {
incr totalFound
set totalCPU [expr {${totalCPU} + ${CPUUsage}}]
}