@@ -34,67 +34,6 @@ static int64_t gettime_i64(void) {
34
34
#endif
35
35
}
36
36
37
- #define FP_EXP (6)
38
- #define FP_MULT (1000000LL)
39
-
40
- /* Format fixed point number. */
41
- static void print_number (const int64_t x ) {
42
- int64_t x_abs , y ;
43
- int c , i , rounding , g ; /* g = integer part size, c = fractional part size */
44
- size_t ptr ;
45
- char buffer [30 ];
46
-
47
- if (x == INT64_MIN ) {
48
- /* Prevent UB. */
49
- printf ("ERR" );
50
- return ;
51
- }
52
- x_abs = x < 0 ? - x : x ;
53
-
54
- /* Determine how many decimals we want to show (more than FP_EXP makes no
55
- * sense). */
56
- y = x_abs ;
57
- c = 0 ;
58
- while (y > 0LL && y < 100LL * FP_MULT && c < FP_EXP ) {
59
- y *= 10LL ;
60
- c ++ ;
61
- }
62
-
63
- /* Round to 'c' decimals. */
64
- y = x_abs ;
65
- rounding = 0 ;
66
- for (i = c ; i < FP_EXP ; ++ i ) {
67
- rounding = (y % 10 ) >= 5 ;
68
- y /= 10 ;
69
- }
70
- y += rounding ;
71
-
72
- /* Format and print the number. */
73
- ptr = sizeof (buffer ) - 1 ;
74
- buffer [ptr ] = 0 ;
75
- g = 0 ;
76
- if (c != 0 ) { /* non zero fractional part */
77
- for (i = 0 ; i < c ; ++ i ) {
78
- buffer [-- ptr ] = '0' + (y % 10 );
79
- y /= 10 ;
80
- }
81
- } else if (c == 0 ) { /* fractional part is 0 */
82
- buffer [-- ptr ] = '0' ;
83
- }
84
- buffer [-- ptr ] = '.' ;
85
- do {
86
- buffer [-- ptr ] = '0' + (y % 10 );
87
- y /= 10 ;
88
- g ++ ;
89
- } while (y != 0 );
90
- if (x < 0 ) {
91
- buffer [-- ptr ] = '-' ;
92
- g ++ ;
93
- }
94
- printf ("%5.*s" , g , & buffer [ptr ]); /* Prints integer part */
95
- printf ("%-*s" , FP_EXP , & buffer [ptr + g ]); /* Prints fractional part */
96
- }
97
-
98
37
static void run_benchmark (char * name , void (* benchmark )(void * , int ), void (* setup )(void * ), void (* teardown )(void * , int ), void * data , int count , int iter ) {
99
38
int i ;
100
39
int64_t min = INT64_MAX ;
@@ -120,13 +59,7 @@ static void run_benchmark(char *name, void (*benchmark)(void*, int), void (*setu
120
59
sum += total ;
121
60
}
122
61
/* ',' is used as a column delimiter */
123
- printf ("%-30s, " , name );
124
- print_number (min * FP_MULT / iter );
125
- printf (" , " );
126
- print_number (((sum * FP_MULT ) / count ) / iter );
127
- printf (" , " );
128
- print_number (max * FP_MULT / iter );
129
- printf ("\n" );
62
+ printf ("%-30s, %.2f, %.2f, %.2f\n\n" , name , (double )min / iter , (double )sum / count / iter , (double )max / iter );
130
63
}
131
64
132
65
static int have_flag (int argc , char * * argv , char * flag ) {
0 commit comments