Toward better CPU idle-time predictions
Toward better CPU idle-time predictions
Posted Oct 30, 2014 21:48 UTC (Thu) by robbe (guest, #16131)In reply to: Toward better CPU idle-time predictions by marcH
Parent article: Toward better CPU idle-time predictions
"relatively constant" in human time scales, but not if you are looking at sub-millisecond timings. Try:
#!/usr/bin/perl
use Term::ReadKey;
use Time::HiRes qw(gettimeofday tv_interval);
ReadMode 'cbreak';
my $k = ReadKey 0;
my $t = [gettimeofday];
while ($k ne "\n" && $k ne "\r") {
$k = ReadKey 0;
my $tt = [gettimeofday];
print tv_interval($t, $tt),"\n";
$t = $tt;
}
ReadMode 0;
For me standard deviation is about 100 ms -- much too jittery to rely on. Remember that the disk events are put in 0.2 ms buckets.
On the other hand, ignoring keypresses may be just the right thing to do. They happen so infrequently! If something more sophisticated is needed, try to find out if user is typing, then err on the side of caution and expect keypresses every 50ms.
