void print_test_results()

in src/util.c [148:276]


void print_test_results(struct ntttcp_test_endpoint *tep)
{
	struct ntttcp_test_endpoint_results *tepr = tep->results;
	uint64_t total_bytes = tepr->total_bytes;
	uint total_conns_created = 0;
	double test_duration = tepr->actual_test_time;

	unsigned int i;
	char *log = NULL, *log_tmp = NULL;

	if (test_duration == 0)
		return;

	if (tep->test->verbose) {
		PRINT_INFO("\tThread\tTime(s)\tThroughput");
		PRINT_INFO("\t======\t=======\t==========");
		for (i = 0; i < tep->total_threads; i++) {
			if (tep->results->threads[i]->is_sync_thread == true)
				continue;

			log_tmp = format_throughput(tepr->threads[i]->total_bytes,
						    tepr->threads[i]->actual_test_time);
			ASPRINTF(&log, "\t%d\t %.2f\t %s", i, tepr->threads[i]->actual_test_time, log_tmp);
			free(log_tmp);
			PRINT_INFO_FREE(log);
		}
	}

	/* only sender/client report the total connections established */
	if (tep->test->client_role == true) {
		for (i = 0; i < tep->total_threads; i++)
			total_conns_created += tep->client_streams[i]->num_conns_created;
		ASPRINTF(&log, "%d connections tested", total_conns_created);
		PRINT_INFO_FREE(log);
	}

	PRINT_INFO("#####  Totals:  #####");
	ASPRINTF(&log, "test duration\t:%.2f seconds", test_duration);
	PRINT_INFO_FREE(log);
	ASPRINTF(&log, "total bytes\t:%" PRIu64, total_bytes);
	PRINT_INFO_FREE(log);

	log_tmp = format_throughput(total_bytes, test_duration);
	ASPRINTF(&log, "\t throughput\t:%s", log_tmp);
	free(log_tmp);
	PRINT_INFO_FREE(log);
	/* only show RetransSegs for TCP traffic */
	if (tepr->endpoint->test->protocol == TCP) {
		ASPRINTF(&log, "\t retrans segs\t:%"PRIu64, tepr->packets_retransmitted);
		PRINT_INFO_FREE(log);
	}

	if (tep->test->show_tcp_retransmit) {
		PRINT_INFO("tcp retransmit:");
		ASPRINTF(&log, "\t retrans_segments/sec\t:%.2f", tepr->retrans_segments_per_sec);
		PRINT_INFO_FREE(log);
		ASPRINTF(&log, "\t lost_retrans/sec\t:%.2f", tepr->tcp_lost_retransmit_per_sec);
		PRINT_INFO_FREE(log);
		ASPRINTF(&log, "\t syn_retrans/sec\t:%.2f", tepr->tcp_syn_retrans_per_sec);
		PRINT_INFO_FREE(log);
		ASPRINTF(&log, "\t fast_retrans/sec\t:%.2f", tepr->tcp_fast_retrans_per_sec);
		PRINT_INFO_FREE(log);
		ASPRINTF(&log, "\t forward_retrans/sec\t:%.2f", tepr->tcp_forward_retrans_per_sec);
		PRINT_INFO_FREE(log);
		ASPRINTF(&log, "\t slowStart_retrans/sec\t:%.2f", tepr->tcp_slowStart_retrans_per_sec);
		PRINT_INFO_FREE(log);
		ASPRINTF(&log, "\t retrans_fail/sec\t:%.2f", tepr->tcp_retrans_fail_per_sec);
		PRINT_INFO_FREE(log);
	}

	if (strcmp(tep->test->show_interface_packets, "")) {
		PRINT_INFO("total packets:");
		ASPRINTF(&log, "\t tx_packets\t:%"PRIu64, tepr->packets_sent);
		PRINT_INFO_FREE(log);
		ASPRINTF(&log, "\t rx_packets\t:%"PRIu64, tepr->packets_received);
		PRINT_INFO_FREE(log);
	}
	if (strcmp(tep->test->show_dev_interrupts, "")) {
		PRINT_INFO("interrupts:");
		ASPRINTF(&log, "\t total\t\t:%" PRIu64, tepr->total_interrupts);
		PRINT_INFO_FREE(log);
	}
	if (strcmp(tep->test->show_interface_packets, "") && strcmp(tep->test->show_dev_interrupts, "")) {
		ASPRINTF(&log, "\t pkts/interrupt\t:%.2f", tepr->packets_per_interrupt);
		PRINT_INFO_FREE(log);
	}

	if (tepr->final_cpu_ps->nproc == tepr->init_cpu_ps->nproc) {
		ASPRINTF(&log, "cpu cores\t:%d", tepr->final_cpu_ps->nproc);
		PRINT_INFO_FREE(log);
	} else {
		ASPRINTF(&log,
			"number of CPUs does not match: initial: %d; final: %d",
			tepr->init_cpu_ps->nproc, tepr->final_cpu_ps->nproc);
		PRINT_ERR_FREE(log);
	}

	ASPRINTF(&log, "\t cpu speed\t:%.3fMHz", tepr->cpu_speed_mhz);
	PRINT_INFO_FREE(log);
	ASPRINTF(&log, "\t user\t\t:%.2f%%", tepr->cpu_ps_user_usage * 100);
	PRINT_INFO_FREE(log);
	ASPRINTF(&log, "\t system\t\t:%.2f%%", tepr->cpu_ps_system_usage * 100);
	PRINT_INFO_FREE(log);
	ASPRINTF(&log, "\t idle\t\t:%.2f%%", tepr->cpu_ps_idle_usage * 100);
	PRINT_INFO_FREE(log);
	ASPRINTF(&log, "\t iowait\t\t:%.2f%%", tepr->cpu_ps_iowait_usage * 100);
	PRINT_INFO_FREE(log);
	ASPRINTF(&log, "\t softirq\t:%.2f%%", tepr->cpu_ps_softirq_usage * 100);
	PRINT_INFO_FREE(log);
	ASPRINTF(&log, "\t cycles/byte\t:%.2f", tepr->cycles_per_byte);
	PRINT_INFO_FREE(log);
	ASPRINTF(&log, "cpu busy (all)\t:%.2f%%", tepr->cpu_busy_percent * 100);
	PRINT_INFO_FREE(log);

	if (tep->test->verbose) {
		if (tep->endpoint_role == ROLE_SENDER && tep->test->protocol == TCP) {
			ASPRINTF(&log, "tcpi rtt\t\t:%u us", tepr->average_rtt);
			PRINT_INFO_FREE(log);
		}
	}
	printf("---------------------------------------------------------\n");

	if (tep->test->save_xml_log)
		if (write_result_into_xml_file(tep) != 0)
			PRINT_ERR("Error writing log to xml file");
	if (tep->test->save_json_log)
		if (write_result_into_json_file(tep) != 0)
			PRINT_ERR("Error writing log to json file");
}