Re: [PATCH 1/3] tools/kvm_stat: add command line switch '-z' to skip zero records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-03-31 23:45, Paolo Bonzini wrote:
> On 31/03/20 22:00, Stefan Raspl wrote:
>> @@ -1523,14 +1535,20 @@ def log(stats, opts, frmt, keys):
>>      """Prints statistics as reiterating key block, multiple value blocks."""
>>      line = 0
>>      banner_repeat = 20
>> +    banner_printed = False
>> +
>>      while True:
>>          try:
>>              time.sleep(opts.set_delay)
>> -            if line % banner_repeat == 0:
>> +            if line % banner_repeat == 0 and not banner_printed:
>>                  print(frmt.get_banner())
>> -            print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") +
>> -                  frmt.get_statline(keys, stats.get()))
>> +                banner_printed = True
> 
> Can't skip_zero_records be handled here instead?
> 
>     values = stats.get()
>     if not opts.skip_zero_records or \
>         any((values[k].delta != 0 for k in keys):
>        statline = frmt.get_statline(keys, values)
>        print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + statline)

I wanted to avoid such an extra check for performance reasons. Granted, I have
to do something likewise (i.e. checking for non-zero values) in my patch for csv
records, but at least for the standard format things are a bit less costly
(avoiding an extra pass over the data).

Ciao,
Stefan




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux