/normxcorr/trunk

To get this branch, use:
bzr branch http://suren.me/webbzr/normxcorr/trunk

« back to all changes in this revision

Viewing changes to dict_hw/src/helpers.h

  • Committer: Suren A. Chilingaryan
  • Date: 2009-12-15 13:54:56 UTC
  • Revision ID: csa@dside.dyndns.org-20091215135456-0q8p63jwg4dzbf6p
Collection of timing information and fix for a crash in non-matlab mode

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    if (n&(n-1)) return -1;
41
41
    else return debruijn[((uint32_t)n * 0x077CB531) >> 27];
42
42
}
 
43
 
 
44
#ifdef DICT_HW_MEASURE_TIMINGS
 
45
#include <string.h>
 
46
static inline void print_timing(const char *msg, int time, int images = 0) {
 
47
    int img_time;
 
48
    char units[4];
 
49
        
 
50
    if (images > 0) img_time = time / images;
 
51
    
 
52
    if (time > 10000000) {
 
53
        time /= 1000000;
 
54
        strcpy(units, "s");
 
55
    } else if (time > 10000) {
 
56
        time /= 1000;
 
57
        strcpy(units, "ms");
 
58
    } else {
 
59
        strcpy(units, "us");
 
60
    }
 
61
 
 
62
    printf("%s%*s", msg, max2(0, 32 - (int)strlen(msg)), "");
 
63
    printf(": %4i %s", time, units);
 
64
 
 
65
    if (images > 0) {
 
66
        time = img_time;
 
67
        if (time > 10000000) {
 
68
            time /= 1000000;
 
69
            strcpy(units, "s");
 
70
        } else if (time > 10000) {
 
71
            time /= 1000;
 
72
            strcpy(units, "ms");
 
73
        } else {
 
74
            strcpy(units, "us");
 
75
        }
 
76
        printf(", %5i images, %4i %s per image", images, time, units);
 
77
    }
 
78
 
 
79
    printf("\n");
 
80
}
 
81
#endif /* DICT_HW_MEASURE_TIMINGS */