@@ -25,6 +25,7 @@ void simulate(reader_t *reader, cache_t *cache, int report_interval,
2525 uint64_t req_cnt = 0 , miss_cnt = 0 ;
2626 uint64_t last_req_cnt = 0 , last_miss_cnt = 0 ;
2727 uint64_t req_byte = 0 , miss_byte = 0 ;
28+ double req_cost = 0 , miss_cost = 0 ;
2829
2930 read_one_req (reader , req );
3031 uint64_t start_ts = (uint64_t )req -> clock_time ;
@@ -52,9 +53,11 @@ void simulate(reader_t *reader, cache_t *cache, int report_interval,
5253
5354 req_cnt ++ ;
5455 req_byte += req -> obj_size ;
56+ req_cost += req -> obj_cost ;
5557 if (cache -> get (cache , req ) == false) {
5658 miss_cnt ++ ;
5759 miss_byte += req -> obj_size ;
60+ miss_cost += req -> obj_cost ;
5861 }
5962 if (req -> clock_time - last_report_ts >= (uint64_t )report_interval &&
6063 req -> clock_time != 0 ) {
@@ -78,24 +81,28 @@ void simulate(reader_t *reader, cache_t *cache, int report_interval,
7881
7982 char output_str [1024 ];
8083 char size_str [64 ];
84+ double byte_miss_ratio = req_byte > 0 ? (double )miss_byte / (double )req_byte : 0.0 ;
85+ double cost_miss_ratio = req_cost > 0 ? miss_cost / req_cost : 0.0 ;
8186
8287 if (!ignore_obj_size ) convert_size_to_str (cache -> cache_size , size_str , 64 );
8388#pragma GCC diagnostic push
8489 // Removed unknown pragma warning
8590 if (!ignore_obj_size ) {
8691 snprintf (output_str , 1024 ,
87- "%s %s cache size %8s, %16lu req, miss ratio %.4lf, throughput "
92+ "%s %s cache size %8s, %16lu req, miss ratio %.4lf, byte miss ratio %.4lf, cost miss ratio %.4lf, throughput "
8893 "%.2lf MQPS\n" ,
8994 reader -> trace_path , detailed_cache_name , size_str ,
9095 (unsigned long )req_cnt , (double )miss_cnt / (double )req_cnt ,
96+ byte_miss_ratio , cost_miss_ratio ,
9197 (double )req_cnt / 1000000.0 / runtime );
9298 } else {
9399 snprintf (output_str , 1024 ,
94- "%s %s cache size %8lld, %16lu req, miss ratio %.4lf, throughput "
100+ "%s %s cache size %8lld, %16lu req, miss ratio %.4lf, byte miss ratio %.4lf, cost miss ratio %.4lf, throughput "
95101 "%.2lf MQPS\n" ,
96102 reader -> trace_path , detailed_cache_name ,
97103 (long long )cache -> cache_size , (unsigned long )req_cnt ,
98104 (double )miss_cnt / (double )req_cnt ,
105+ byte_miss_ratio , cost_miss_ratio ,
99106 (double )req_cnt / 1000000.0 / runtime );
100107 }
101108
0 commit comments