User interactivity measurements.

From: James Courtier-Dutton
Date: Sat Sep 25 2010 - 07:02:35 EST


Hi,

I was trying to work out how I would measure how good the user interactivity is.
I thought that I could use the keyboard repeat rate to do this.
The repeat rate should be constant, so if I measure it, any large
variations indicate latency problems.
The attach program measures the repeat rate that is observed by the application.
To use the program, just keep the ENTER key down until the program exists.
Compile it with "gcc k.c"
Run it with "./a.out >output" and then examine the output in file "output"

Example output under xfce4
0.050032, 0
0.049969, 0
0.050017, 0
0.049970, 0
0.050034, 0
0.049970, 0
0.050038, 0
0.049962, 0
0.049934, 0
0.049987, 0
0.049980, 0
0.060135, 1
0.049878, 0
0.050150, 0
0.049934, 0

As you can see, only one value that is far away from the normal of
0.050000 seconds.
The 1 in the last column tries to identify problem values.

Example output from the same computer, but under gnome and compiz.
0.049984, 1
0.040191, 1
0.029801, 0
0.040048, 1
0.040022, 1
0.029998, 0
0.049945, 1
0.030110, 0
0.049925, 1
0.050020, 1
0.039993, 1
0.039969, 1

As you can see, the variability under gnome and compiz is far worse
than xfce4 with the normal value being about 0.030000 seconds. In
fact, it is so variable, that it is hard to tell what the normal value
should be!!! There appear to be values clumped around 0.4, and around
0.3 and around 0.5.


Can anyone spot any problems with this approach to measuring the user
interactivity and perceived latency.
For me, the latency was far worse, to the eye, on gnome/compiz than
xfce4 and these results seem to prove it.

Kind Regards

James
#include <stdio.h>
#include <sys/time.h>
#include <inttypes.h>

int main() {
int key;
int n;
int tmp;
uint64_t total = 0;
int size = 100;
int repeat_rate = 30000;
struct timeval time1[size];
struct timeval time2;
struct timeval timediff;
/* Add one because we drop the first key */
size++;

fprintf(stderr, "Press and hold ENTER key\n");
tmp = gettimeofday(&time1[0], NULL);
for (n = 1; n < size; n++) {
key = getchar();
tmp = gettimeofday(&time1[n], NULL);
}
/* Ignore the first key */
for (n = 2; n < size; n++) {
timediff.tv_sec = time1[n].tv_sec - time1[n-1].tv_sec;
timediff.tv_usec = time1[n].tv_usec - time1[n-1].tv_usec;
if (timediff.tv_usec < 0) {
timediff.tv_usec += 1000000;
timediff.tv_sec -= 1;
}
total += timediff.tv_usec;
tmp = 0;
if ((timediff.tv_usec > (repeat_rate + 1000)) || (timediff.tv_usec < (repeat_rate - 1000))) tmp = 1;
printf("%ld.%06ld, %d\n", timediff.tv_sec, timediff.tv_usec, tmp);
}
printf("Total = %lu\n", total / (size - 1));
}