2323#define CPP_MODULE " MAIN"
2424#define ITERATIONS 10
2525
26- #define TIMER_START () time_start = std::chrono::steady_clock::now();
27- #define TIMER_END () \
28- time_end = std::chrono::steady_clock::now(); \
29- time_total = std::chrono::duration<double , std::milli>(time_end - time_start).count();
30- #define TIMER_PRINT (name ) std::cout << name <<" : " << time_total / 1e3 << " s\n " ;
26+ #define TIMER_START (name ) time_start_ ## name = std::chrono::steady_clock::now();
27+ #define TIMER_END (name ) \
28+ time_ ## name = std::chrono::duration<double , std::milli>( \
29+ std::chrono::steady_clock::now () - time_start_ ## name \
30+ ).count();
31+ #define TIMER_PRINT (name, msg ) std::cout << msg <<" : " << time_ ## name / 1e3 << " s\n " ;
3132
3233#ifdef DEBUG_TIME
3334#define START_TIMER () start_time = std::chrono::steady_clock::now();
@@ -153,9 +154,10 @@ void test_correctness(
153154
154155int main (int argc, char * argv[])
155156{
156- std::chrono::steady_clock::time_point time_start ;
157- std::chrono::steady_clock::time_point time_end ;
157+ std::chrono::steady_clock::time_point time_start_total ;
158+ std::chrono::steady_clock::time_point time_start_compute ;
158159 double time_total = 0.0 ;
160+ double time_compute = 0.0 ;
159161
160162 try {
161163
@@ -190,7 +192,7 @@ STOP_TIMER();
190192PRINT_TIMER (" generate_hashtable " );
191193#endif
192194
193- TIMER_START ()
195+ TIMER_START (total )
194196
195197#ifdef DEBUG_TIME
196198START_TIMER ();
@@ -202,6 +204,8 @@ STOP_TIMER();
202204PRINT_TIMER (" init " );
203205#endif
204206
207+ TIMER_START (compute)
208+
205209 std::vector<KeyValue> kvs;
206210 for (int iter = 0 ; iter < ITERATIONS; iter++) {
207211#ifdef DEBUG_TIME
@@ -281,9 +285,11 @@ PRINT_TIMER("iterate_hashtable ");
281285
282286 destroy_hashtable (pHashTable, qht);
283287 }
284- TIMER_END ()
285- TIMER_PRINT (" hashtable - total time for whole calculation" )
286- printf (" %f million keys/second\n " , kNumKeyValues / (time_total / ITERATIONS / 1000 .0f ) / 1000000 .0f );
288+ TIMER_END (compute)
289+ TIMER_END (total)
290+ TIMER_PRINT (compute, " hashtable - compute time" )
291+ TIMER_PRINT (total, " hashtable - total time for whole calculation" )
292+ printf (" %f million keys/second\n " , kNumKeyValues / (time_compute / ITERATIONS / 1000 .0f ) / 1000000 .0f );
287293
288294 if (verify) {
289295 test_unordered_map (insert_kvs, delete_kvs);
0 commit comments