|
1 | 1 | #include <binsparse/binsparse.h> |
2 | 2 | #include <stdio.h> |
3 | 3 |
|
| 4 | +#include <time.h> |
| 5 | + |
| 6 | +double gettime() { |
| 7 | + struct timespec time; |
| 8 | + clock_gettime(CLOCK_MONOTONIC, &time); |
| 9 | + return ((double) time.tv_sec) + ((double) 1e-9) * time.tv_nsec; |
| 10 | +} |
| 11 | + |
4 | 12 | int main(int argc, char** argv) { |
5 | 13 |
|
6 | 14 | if (argc < 3) { |
@@ -112,26 +120,48 @@ int main(int argc, char** argv) { |
112 | 120 | cJSON_AddStringToObject(user_json, "comment", m.comments); |
113 | 121 |
|
114 | 122 | printf(" === Reading file... ===\n"); |
| 123 | + double begin = gettime(); |
115 | 124 | bsp_matrix_t matrix = bsp_mmread(input_fname); |
| 125 | + double end = gettime(); |
116 | 126 | printf(" === Done reading. ===\n"); |
117 | 127 |
|
| 128 | + double duration = end - begin; |
| 129 | + printf("%lf seconds reading Matrix Market file...\n", duration); |
| 130 | + |
118 | 131 | if (perform_suitesparse_declamping) { |
| 132 | + begin = gettime(); |
119 | 133 | bsp_matrix_declamp_values(matrix); |
| 134 | + end = gettime(); |
| 135 | + duration = end - begin; |
| 136 | + printf("%lf seconds declamping...\n", duration); |
120 | 137 | } |
121 | 138 |
|
| 139 | + begin = gettime(); |
122 | 140 | matrix = bsp_matrix_minimize_values(matrix); |
| 141 | + end = gettime(); |
| 142 | + duration = end - begin; |
| 143 | + printf("%lf seconds minimizing values...\n", duration); |
123 | 144 |
|
124 | 145 | if (format != BSP_COOR) { |
| 146 | + begin = gettime(); |
125 | 147 | bsp_matrix_t converted_matrix = bsp_convert_matrix(matrix, format); |
126 | 148 | bsp_destroy_matrix_t(matrix); |
127 | 149 | matrix = converted_matrix; |
| 150 | + end = gettime(); |
| 151 | + duration = end - begin; |
| 152 | + printf("%lf seconds converting to %s format...\n", duration, |
| 153 | + bsp_get_matrix_format_string(format)); |
128 | 154 | } |
129 | 155 |
|
130 | 156 | bsp_print_matrix_info(matrix); |
131 | 157 |
|
132 | 158 | printf(" === Writing to %s... ===\n", output_fname); |
| 159 | + begin = gettime(); |
133 | 160 | bsp_write_matrix(output_fname, matrix, group_name, user_json, |
134 | 161 | compression_level); |
| 162 | + end = gettime(); |
| 163 | + duration = end - begin; |
| 164 | + printf("%lf seconds writing Binsparse file...\n", duration); |
135 | 165 | printf(" === Done writing. ===\n"); |
136 | 166 |
|
137 | 167 | bsp_destroy_matrix_t(matrix); |
|
0 commit comments