Best way to time this chip?

7 posts
by RichardUK » Sun Jun 10, 2012 9:16 pm
Anyone know a good way to time gl calls? I ask as I've not done this kind of timing on Linux before, in the past on other platforms I have found timing API functions can only give you a vague guess on what is costing. But even this would be handy.

If I can say 'Hi, function X is costing 100ms' to the driver guys they can then go and have a look and give a reason.
User avatar
Posts: 205
Joined: Fri Jun 01, 2012 5:12 pm
by dave j » Sun Jun 10, 2012 10:41 pm
If this is for your glUniformMatrix4fv problem, the driver guys will want a minimal program that demonstrates the problem. That makes sure a) they can reproduce the exact circumstances that cause the problem rather than guessing what you've been trying to do and b) they have an easy way to tell if they've fixed you problem.

Searching for "linux high resolution timers" brings back lots of candidates but, as I don't have an RPi yet, I'm afraid I can't advise on the best one.
Posts: 94
Joined: Mon Mar 05, 2012 2:19 pm
by dom » Sun Jun 10, 2012 10:55 pm
High resolution timers are supported. gettimeofday has microsecond resolution.

#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
int delay = 500;
struct timeval start, stop;
if (argc > 1) delay = atoi(argv[1]);
gettimeofday(&start, NULL);
gettimeofday(&stop, NULL);
printf("Elapsed %d\n", (int)((stop.tv_sec-start.tv_sec)*1000000ULL+(stop.tv_usec-start.tv_usec)));
return 0;
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5070
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by RichardUK » Mon Jun 11, 2012 1:05 pm
Thanks guys, will play with this when I get home. Yes, if I do find an issue I'll make a single source file test app for the driver team.
User avatar
Posts: 205
Joined: Fri Jun 01, 2012 5:12 pm
by devon » Sat Jul 07, 2012 2:42 pm
Perhaps take a look at clock_gettime.
Posts: 5
Joined: Wed Jun 13, 2012 4:43 pm
by jmacey » Sun Jul 08, 2012 8:16 am
Posts: 135
Joined: Thu May 31, 2012 1:05 pm
by xernobyl » Fri Jul 20, 2012 4:14 pm
What's the fastest thing to time the RPi? The aforementioned functions which I usually use on Linux could probably be faster on a fixed platform like the RPi. There's probably a couple of registers we can peek.
Posts: 26
Joined: Tue Oct 25, 2011 2:03 pm