Skip to content

Commit d5a4cca

Browse files
Added Totals to csv
1 parent d7cccbf commit d5a4cca

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

memtier_benchmark.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,7 @@ run_stats run_benchmark(int run_id, benchmark_config* cfg, object_generator* obj
15221522
// Merge all threads for this second to get accurate aggregated percentiles
15231523
std::vector<double> set_percentiles;
15241524
std::vector<double> get_percentiles;
1525+
std::vector<double> total_percentiles;
15251526

15261527
if (cfg->print_percentiles.quantile_list.size() > 0) {
15271528
// Create temporary stats and merge all threads for this second
@@ -1540,14 +1541,16 @@ run_stats run_benchmark(int run_id, benchmark_config* cfg, object_generator* obj
15401541
const one_second_stats& latest_second = stats_list.back();
15411542
set_percentiles = latest_second.m_set_cmd.summarized_quantile_values;
15421543
get_percentiles = latest_second.m_get_cmd.summarized_quantile_values;
1544+
total_percentiles = latest_second.m_total_cmd.summarized_quantile_values;
15431545
}
15441546
}
15451547

15461548
// Use the properly aggregated percentile data!
15471549
run_stats::write_csv_realtime_data(csv_file, second_counter, active_connections, cur_connection_errors,
15481550
cur_ops, cur_bytes, cur_latency, cfg,
15491551
set_percentiles.empty() ? nullptr : &set_percentiles,
1550-
get_percentiles.empty() ? nullptr : &get_percentiles);
1552+
get_percentiles.empty() ? nullptr : &get_percentiles,
1553+
total_percentiles.empty() ? nullptr : &total_percentiles);
15511554
}
15521555
} while (active_threads > 0);
15531556

run_stats.cpp

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,15 @@ void run_stats::save_csv_one_sec(FILE *f,
406406
fprintf(f, ",WAIT p%.1f Latency", quantile);
407407
}
408408

409+
// Add TOTAL columns (matching JSON structure)
410+
fprintf(f, ",TOTAL Requests,TOTAL Average Latency,TOTAL Total Bytes,TOTAL Total Bytes TX,TOTAL Total Bytes RX");
411+
412+
// Add TOTAL percentile columns
413+
for (std::size_t i = 0; i < m_config->print_percentiles.quantile_list.size(); i++) {
414+
float quantile = m_config->print_percentiles.quantile_list[i];
415+
fprintf(f, ",TOTAL p%.1f Latency", quantile);
416+
}
417+
409418
fprintf(f, ",Active Connections,Connection Errors\n");
410419

411420
total_get_ops = 0;
@@ -453,6 +462,19 @@ void run_stats::save_csv_one_sec(FILE *f,
453462
fprintf(f, ",%.3f", i->m_wait_cmd.summarized_quantile_values[p]);
454463
}
455464

465+
// Write TOTAL data (SET + GET combined)
466+
fprintf(f, ",%lu,%u.%06u,%lu,%lu,%lu",
467+
i->m_total_cmd.m_ops,
468+
USEC_FORMAT(AVERAGE(i->m_total_cmd.m_total_latency, i->m_total_cmd.m_ops)),
469+
i->m_total_cmd.m_bytes_rx + i->m_total_cmd.m_bytes_tx,
470+
i->m_total_cmd.m_bytes_tx,
471+
i->m_total_cmd.m_bytes_rx);
472+
473+
// Write TOTAL percentiles
474+
for (std::size_t p = 0; p < i->m_total_cmd.summarized_quantile_values.size(); p++) {
475+
fprintf(f, ",%.3f", i->m_total_cmd.summarized_quantile_values[p]);
476+
}
477+
456478
// Write connection data
457479
fprintf(f, ",%u,%u\n", i->m_active_connections, i->m_connection_errors);
458480

@@ -838,14 +860,24 @@ bool run_stats::write_csv_header(FILE *f, benchmark_config *config)
838860
fprintf(f, ",WAIT p%.1f Latency", quantile);
839861
}
840862

863+
// Add TOTAL columns (matching JSON structure)
864+
fprintf(f, ",TOTAL Requests,TOTAL Average Latency,TOTAL Total Bytes,TOTAL Total Bytes TX,TOTAL Total Bytes RX");
865+
866+
// Add TOTAL percentile columns
867+
for (std::size_t i = 0; i < config->print_percentiles.quantile_list.size(); i++) {
868+
float quantile = config->print_percentiles.quantile_list[i];
869+
fprintf(f, ",TOTAL p%.1f Latency", quantile);
870+
}
871+
841872
fprintf(f, ",Active Connections,Connection Errors\n");
842873
fflush(f);
843874
return true;
844875
}
845876

846877
bool run_stats::write_csv_realtime_data(FILE *f, unsigned int second, unsigned int active_connections, unsigned int connection_errors,
847878
unsigned long int cur_ops, unsigned long int cur_bytes, double cur_latency, benchmark_config *config,
848-
const std::vector<double>* set_percentiles, const std::vector<double>* get_percentiles)
879+
const std::vector<double>* set_percentiles, const std::vector<double>* get_percentiles,
880+
const std::vector<double>* total_percentiles)
849881
{
850882
if (!f) return false;
851883

@@ -908,6 +940,20 @@ bool run_stats::write_csv_realtime_data(FILE *f, unsigned int second, unsigned i
908940
fprintf(f, ",0.000");
909941
}
910942

943+
// Write TOTAL data (SET + GET combined)
944+
unsigned long int total_ops = cur_ops;
945+
unsigned long int total_bytes = cur_bytes;
946+
fprintf(f, ",%lu,%.6f,%lu,%lu,0", total_ops, cur_latency, total_bytes, total_bytes);
947+
948+
// Write TOTAL percentiles (use actual TOTAL percentiles if available)
949+
for (std::size_t i = 0; i < config->print_percentiles.quantile_list.size(); i++) {
950+
if (total_percentiles && i < total_percentiles->size()) {
951+
fprintf(f, ",%.3f", (*total_percentiles)[i]);
952+
} else {
953+
fprintf(f, ",%.3f", cur_latency);
954+
}
955+
}
956+
911957
// Write connection data
912958
fprintf(f, ",%u,%u\n", active_connections, connection_errors);
913959

run_stats.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ class run_stats {
182182
static bool write_csv_header(FILE *f, benchmark_config *config);
183183
static bool write_csv_realtime_data(FILE *f, unsigned int second, unsigned int active_connections, unsigned int connection_errors,
184184
unsigned long int cur_ops, unsigned long int cur_bytes, double cur_latency, benchmark_config *config,
185-
const std::vector<double>* set_percentiles = nullptr, const std::vector<double>* get_percentiles = nullptr);
185+
const std::vector<double>* set_percentiles = nullptr, const std::vector<double>* get_percentiles = nullptr,
186+
const std::vector<double>* total_percentiles = nullptr);
186187
void debug_dump(void);
187188

188189
// function to handle the results output

0 commit comments

Comments
 (0)