Commit fd20bd9e authored by Joanne Hugé's avatar Joanne Hugé

Make print go to beginning of line instead of printing multiple lines

parent 96d6ef68
......@@ -211,16 +211,16 @@ int main(int argc, char *argv[]) {
if (main_param.verbose) {
if (tsn_task == RTT_TASK) {
printf("RTT: %*" PRIu64 " (%*d)\n", 10, stats->rtt, 10, stats->nb_cycles);
printf("%*d: RTT: %*" PRIu64 "\n", 10, stats->nb_cycles, 10, stats->rtt);
printf("\033[%dA", 1);
} else if (enable_timestamps) {
int64_t user_space_time = stats->packet_info.userspace_exit_ts - stats->packet_info.userspace_enter_ts;
int64_t kernel_space_time = stats->packet_info.kernelspace_ts - stats->packet_info.userspace_exit_ts;
printf("(%*d) User and kernel space time: %*" PRIi64 ", %" PRIi64 "\n",
10, stats->nb_cycles, 10, user_space_time, kernel_space_time);
printf("%*d: U: %*" PRIi64 ", K: %*" PRIi64 "\n",
10, stats->nb_cycles, 10, user_space_time, 10, kernel_space_time);
printf("\033[%dA", 1);
}
}
......
......@@ -178,7 +178,6 @@ static void *packet_receiving_thread(void *p) {
int main(int argc, char *argv[]) {
pthread_t thread;
thread_stat_t *stats;
int64_t diff;
param = malloc(sizeof(thread_param_t));
stats = &param->stats;
......@@ -226,21 +225,29 @@ int main(int argc, char *argv[]) {
if (main_param.verbose) {
if (tsn_task == RECV_PACKET_TASK) {
diff = ((int64_t)stats->max_interval) - stats->min_interval;
printf("(%*d) Jitter : %*" PRIi64 " [Packet data: %*s] [Lost packets: %*d]\n",
int64_t jitter = ((int64_t)stats->max_interval) - stats->min_interval;
printf("%*d: J: %*" PRIi64,
10, stats->packets_received,
10, diff,
10, stats->packet_info.data,
10, stats->lost_packets);
10, jitter);
if (enable_timestamps) {
int64_t user_space_time = stats->packet_info.userspace_exit_ts - stats->packet_info.userspace_enter_ts;
int64_t kernel_space_time = stats->packet_info.kernelspace_ts - stats->packet_info.userspace_exit_ts;
printf("(%*d) User and kernel space time: %*" PRIi64 ", %" PRIi64 "\n",
10, stats->packets_received, 10, user_space_time, kernel_space_time);
printf(", U: %*" PRIi64 ", K: %*" PRIi64 ", D: %*s, L: %*d\n",
10, user_space_time,
10, kernel_space_time,
4, stats->packet_info.data,
4, stats->lost_packets);
}
else {
printf("\n");
}
printf("\033[%dA", 1);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment