X-Git-Url: https://git.lttng.org/?p=lttngtop.git;a=blobdiff_plain;f=src%2Fcursesdisplay.c;h=e4565ede33708d4410842062d86c6f0a7fe87d78;hp=acf5753008490925b019c3241838e8c63e2d9d3d;hb=91be6bb5a6b9a1485b2daceb7152f545d3566e0c;hpb=928f18a6c02cf1eaafb7b60cb72860ed68d7456b;ds=sidebyside diff --git a/src/cursesdisplay.c b/src/cursesdisplay.c index acf5753..e4565ed 100644 --- a/src/cursesdisplay.c +++ b/src/cursesdisplay.c @@ -261,20 +261,42 @@ void basic_header() wrefresh(header); } +struct tm format_timestamp(uint64_t timestamp) +{ + struct tm tm; + uint64_t ts_sec = 0, ts_nsec; + time_t time_s; + + ts_nsec = timestamp; + ts_sec += ts_nsec / NSEC_PER_SEC; + ts_nsec = ts_nsec % NSEC_PER_SEC; + + time_s = (time_t) ts_sec; + + localtime_r(&time_s, &tm); + + return tm; +} + void update_header() { + struct tm start, end; + uint64_t ts_nsec_start, ts_nsec_end; + + ts_nsec_start = data->start % NSEC_PER_SEC; + start = format_timestamp(data->start); + + ts_nsec_end = data->end % NSEC_PER_SEC; + end = format_timestamp(data->end); + werase(header); box(header, 0 , 0); set_window_title(header, "Statistics for interval "); wattron(header, A_BOLD); - /* - wprintw(header, "[%lu.%lu, %lu.%lu[", - data->start.tv_sec, data->start.tv_nsec, - data->end.tv_sec, data->end.tv_nsec); - */ - wprintw(header, "[%lu, %lu[", - data->start, - data->end); + + wprintw(header, "[%02d:%02d:%02d.%09" PRIu64 ", %02d:%02d:%02d.%09" PRIu64 "[", + start.tm_hour, start.tm_min, start.tm_sec, ts_nsec_start, + end.tm_hour, end.tm_min, end.tm_sec, ts_nsec_end); mvwprintw(header, 1, 4, "CPUs"); wattroff(header, A_BOLD); wprintw(header, "\t%d\t(max/cpu : %0.2f%)", data->cpu_table->len, @@ -505,7 +527,7 @@ void update_perf() g_ptr_array_sort_with_data(data->process_table, sort_perf, perf_key); - for (i = 0; i < data->process_table->len && + for (i = 0; i < data->process_table->len && nblinedisplayed < max_center_lines; i++) { tmp = g_ptr_array_index(data->process_table, i);