in src/util.c [353:461]
int write_result_into_xml_file(struct ntttcp_test_endpoint *tep)
{
struct ntttcp_test *test = tep->test;
struct ntttcp_test_endpoint_results *tepr = tep->results;
char hostname[256];
char *os_info = NULL;
char os_info_escaped[2048];
size_t count = 0;
unsigned int i;
memset(hostname, '\0', sizeof(char) * 256);
memset(os_info_escaped, '\0', sizeof(char) * 2048);
FILE *logfile = fopen(test->xml_log_filename, "w");
if (logfile == NULL) {
PRINT_ERR("Error opening file to write log");
return -1;
}
gethostname(hostname, 256);
fprintf(logfile, "<ntttcp%s computername=\"%s\" version=\"5.33-linux\">\n", tep->endpoint_role == ROLE_RECEIVER ? "r" : "s", hostname);
fprintf(logfile, " <parameters>\n");
fprintf(logfile, " <send_socket_buff>%lu</send_socket_buff>\n", test->send_buf_size);
fprintf(logfile, " <recv_socket_buff>%lu</recv_socket_buff>\n", test->recv_buf_size);
fprintf(logfile, " <port>%d</port>\n", test->server_base_port);
fprintf(logfile, " <sync_port>%d</sync_port>\n", test->server_base_port - 1);
fprintf(logfile, " <no_sync>%s</no_sync>\n", test->no_synch == 0 ? "False" : "True");
fprintf(logfile, " <wait_timeout_milliseconds>%d</wait_timeout_milliseconds>\n", 0);
fprintf(logfile, " <async>%s</async>\n", "False");
fprintf(logfile, " <verbose>%s</verbose>\n", test->verbose ? "True" : "False");
fprintf(logfile, " <wsa>%s</wsa>\n", "False");
fprintf(logfile, " <use_ipv6>%s</use_ipv6>\n", test->domain == AF_INET6 ? "True" : "False");
fprintf(logfile, " <udp>%s</udp>\n", test->protocol == UDP ? "True" : "False");
fprintf(logfile, " <verify_data>%s</verify_data>\n", "False");
fprintf(logfile, " <wait_all>%s</wait_all>\n", "False");
fprintf(logfile, " <run_time>%d</run_time>\n", test->duration);
fprintf(logfile, " <warmup_time>%d</warmup_time>\n", test->warmup);
fprintf(logfile, " <cooldown_time>%d</cooldown_time>\n", test->cooldown);
fprintf(logfile, " <dash_n_timeout>%d</dash_n_timeout>\n", 0);
fprintf(logfile, " <bind_sender>%s</bind_sender>\n", "False");
fprintf(logfile, " <sender_name>%s</sender_name>\n", "NA");
fprintf(logfile, " <max_active_threads>%d</max_active_threads>\n", 0);
fprintf(logfile, " <tp>%s</tp>\n", "False");
fprintf(logfile, " <no_stdio_buffer>%s</no_stdio_buffer>\n", "False");
fprintf(logfile, " <throughput_Bpms>%d</throughput_Bpms>\n", 0);
fprintf(logfile, " <cpu_burn>%d</cpu_burn>\n", 0);
fprintf(logfile, " <latency_measurement>%s</latency_measurement>\n", "False");
fprintf(logfile, " <use_io_compl_ports>%s</use_io_compl_ports>\n", "NA");
fprintf(logfile, " <cpu_from_idle_flag>%s</cpu_from_idle_flag>\n", "False");
fprintf(logfile, " <get_estats>%s</get_estats>\n", "False");
fprintf(logfile, " <qos_flag>%s</qos_flag>\n", "False");
fprintf(logfile, " <jitter_measurement>%s</jitter_measurement>\n", "False");
fprintf(logfile, " <packet_spacing>%d</packet_spacing>\n", 0);
fprintf(logfile, " </parameters>\n");
if (test->verbose) {
for (i = 0; i < tep->total_threads; i++) {
if (tep->results->threads[i]->is_sync_thread == true)
continue;
fprintf(logfile, " <thread index=\"%i\">\n", i);
fprintf(logfile, " <realtime metric=\"s\">%.3f</realtime>\n", tepr->threads[i]->actual_test_time);
fprintf(logfile, " <throughput metric=\"KB/s\">%.3f</throughput>\n", tepr->threads[i]->KBps);
fprintf(logfile, " <throughput metric=\"MB/s\">%.3f</throughput>\n", tepr->threads[i]->MBps);
fprintf(logfile, " <throughput metric=\"mbps\">%.3f</throughput>\n", tepr->threads[i]->mbps);
fprintf(logfile, " <avg_bytes_per_compl metric=\"B\">%.3f</avg_bytes_per_compl>\n", 0.000);
fprintf(logfile, " </thread>\n");
}
}
fprintf(logfile, " <total_bytes metric=\"MB\">%.6f</total_bytes>\n", tepr->total_bytes_MB);
fprintf(logfile, " <realtime metric=\"s\">%.6f</realtime>\n", tepr->actual_test_time);
fprintf(logfile, " <avg_bytes_per_compl metric=\"B\">%.3f</avg_bytes_per_compl>\n", 0.000);
fprintf(logfile, " <threads_avg_bytes_per_compl metric=\"B\">%.3f</threads_avg_bytes_per_compl>\n", 0.000);
fprintf(logfile, " <avg_frame_size metric=\"B\">%.3f</avg_frame_size>\n", 0.000);
fprintf(logfile, " <throughput metric=\"MB/s\">%.3f</throughput>\n", tepr->throughput_MBps);
fprintf(logfile, " <throughput metric=\"mbps\">%.3f</throughput>\n", tepr->throughput_mbps);
fprintf(logfile, " <throughput metric=\"Bps\">%.3f</throughput>\n", tepr->throughput_Bps);
fprintf(logfile, " <total_buffers>%.3f</total_buffers>\n", 0.000);
fprintf(logfile, " <throughput metric=\"buffers/s\">%.3f</throughput>\n", 0.000);
fprintf(logfile, " <avg_packets_per_interrupt metric=\"packets/interrupt\">%.3f</avg_packets_per_interrupt>\n", tepr->packets_per_interrupt);
fprintf(logfile, " <interrupts metric=\"count/sec\">%.3f</interrupts>\n", 0.000);
fprintf(logfile, " <dpcs metric=\"count/sec\">%.3f</dpcs>\n", 0.000);
fprintf(logfile, " <avg_packets_per_dpc metric=\"packets/dpc\">%.3f</avg_packets_per_dpc>\n", 0.000);
fprintf(logfile, " <cycles metric=\"cycles/byte\">%.3f</cycles>\n", tepr->cycles_per_byte);
fprintf(logfile, " <packets_sent>%" PRIu64 "</packets_sent>\n", tepr->packets_sent);
fprintf(logfile, " <packets_received>%" PRIu64 "</packets_received>\n", tepr->packets_received);
fprintf(logfile, " <packets_retransmitted>%" PRIu64 "</packets_retransmitted>\n", tepr->packets_retransmitted);
fprintf(logfile, " <errors>%d</errors>\n", tepr->errors);
fprintf(logfile, " <cpu metric=\"%%\">%.3f</cpu>\n", tepr->cpu_busy_percent * 100);
fprintf(logfile, " <bufferCount>%u</bufferCount>\n", 0);
fprintf(logfile, " <bufferLen>%u</bufferLen>\n", 0);
fprintf(logfile, " <io>%u</io>\n", 0);
if (tep->endpoint_role == ROLE_SENDER && test->protocol == TCP) {
fprintf(logfile, " <tcp_average_rtt metric=\"us\">%u</tcp_average_rtt>\n", tepr->average_rtt);
}
count = execute_system_cmd_by_process("uname -a", "r", &os_info);
if (os_info) {
escape_char_for_xml(os_info, os_info_escaped);
free(os_info);
}
fprintf(logfile, " <os>%s</os>\n", count == 0 ? "Unknown" : os_info_escaped);
fprintf(logfile, "</ntttcp%s>\n", tep->endpoint_role == ROLE_RECEIVER ? "r": "s");
fclose(logfile);
return 0;
}