/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 19:24:16 UTC
  • Revision ID: csa@dside.dyndns.org-20091215192416-hsqqyaivreiw1gso
Print timings using reportMessage calls

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
# include <stdint.h>
11
11
#endif
12
12
 
 
13
#if MSVCPP
 
14
# define ALGNW __declspec(align(16))
 
15
# define ALGNL
 
16
#else
 
17
# define ALGNW
 
18
# define ALGNL __attribute__((aligned(16)))
 
19
#endif
 
20
 
 
21
 
13
22
#define max4(a,b,c,d) max2(max2(a,b),max2(c,d))
14
23
#define max3(a,b,c) max2(max2(a,b),c)
15
24
#define max2(a,b) (((a)>(b))?(a):(b))
43
52
 
44
53
#ifdef DICT_HW_MEASURE_TIMINGS
45
54
#include <string.h>
 
55
#include "normxcorr_hw_msg.h"
46
56
static inline void print_timing(const char *msg, int time, int images = 0) {
 
57
    int len;
47
58
    int img_time;
48
59
    char units[4];
 
60
    char tmp[128];
49
61
        
50
62
    if (images > 0) img_time = time / images;
51
63
    
52
64
    if (time > 10000000) {
53
65
        time /= 1000000;
54
 
        strcpy(units, "s");
 
66
        strcpy(units, "s ");
55
67
    } else if (time > 10000) {
56
68
        time /= 1000;
57
69
        strcpy(units, "ms");
59
71
        strcpy(units, "us");
60
72
    }
61
73
 
62
 
    printf("%s%*s", msg, max2(0, 32 - (int)strlen(msg)), "");
63
 
    printf(": %4i %s", time, units);
 
74
    strncpy(tmp, msg, 32);
 
75
    tmp[32] = 0;
 
76
    len = strlen(tmp);
 
77
    if (len < 32) {
 
78
        sprintf(tmp + len, "%*s", max2(0, 32 - len), "");
 
79
    }
64
80
 
 
81
    sprintf(tmp + 32, ": %4i %s", time, units);         //< 16
 
82
    
65
83
    if (images > 0) {
66
84
        time = img_time;
67
85
        if (time > 10000000) {
68
86
            time /= 1000000;
69
 
            strcpy(units, "s");
 
87
            strcpy(units, "s ");
70
88
        } else if (time > 10000) {
71
89
            time /= 1000;
72
90
            strcpy(units, "ms");
73
91
        } else {
74
92
            strcpy(units, "us");
75
93
        }
76
 
        printf(", %5i images, %4i %s per image", images, time, units);
 
94
        len = 32 + strlen(tmp + 32);
 
95
        sprintf(tmp + len, ", %5i images, %4i %s per image", images, time, units);      // < 48
77
96
    }
78
97
 
79
 
    printf("\n");
 
98
    reportMessage(tmp);
80
99
}
81
100
#endif /* DICT_HW_MEASURE_TIMINGS */