8 #include <pico/pico_int.h>
10 struct pp_counters *pp_counters;
15 int this_is_new_shmem = 1;
20 unsigned int tmp = pprof_get_one();
21 printf("pprof: measured diff is %u\n", pprof_get_one() - tmp);
24 shmemkey = ftok(".", 0x02ABC32E);
27 perror("pprof: ftok failed");
32 shmemid = shmget(shmemkey, sizeof(*pp_counters),
33 IPC_CREAT | IPC_EXCL | 0644);
37 shmemid = shmget(shmemkey, sizeof(*pp_counters),
41 perror("pprof: shmget failed");
44 this_is_new_shmem = 0;
47 shmem = shmat(shmemid, NULL, 0);
48 if (shmem == (void *)-1)
50 perror("pprof: shmat failed");
55 if (this_is_new_shmem) {
56 memset(pp_counters, 0, sizeof(*pp_counters));
57 printf("pprof: pp_counters cleared.\n");
61 void pprof_finish(void)
64 shmctl(shmemid, IPC_RMID, NULL);
69 #define IT(n) { pp_##n, #n }
85 int main(int argc, char *argv[])
87 unsigned long long old[pp_total_points], new[pp_total_points];
92 if (pp_counters == NULL)
98 memset(old, 0, sizeof(old));
101 if ((l & 0x1f) == 0) {
102 for (i = 0; i < ARRAY_SIZE(pp_tab); i++)
103 printf("%6s ", pp_tab[i].name);
107 memcpy(new, pp_counters->counter, sizeof(new));
108 for (i = 0; i < ARRAY_SIZE(pp_tab); i++)
110 unsigned long long idiff = new[i] - old[i];
111 unsigned long long bdiff = (new[base] - old[base]) | 1;
112 printf("%6.2f ", (double)idiff * 100.0 / bdiff);
115 memcpy(old, new, sizeof(old));
119 usleep(atoi(argv[2]));