diff options
author | Anders Broman <anders.broman@ericsson.com> | 2009-08-28 05:19:52 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2009-08-28 05:19:52 +0000 |
commit | 2cd2eecd0a470bb326c658157d32bfe614698ad0 (patch) | |
tree | 61e3db1ee1afe7d1c8f3f01c12208caa28c7c210 | |
parent | 5cba22a89b913c580c9ca20dd0622ee4fb10b12b (diff) |
Compute the loading time and show it in the main status bar.
(Modified code from Didier Gautheron).
svn path=/trunk/; revision=29592
-rw-r--r-- | file.c | 21 | ||||
-rw-r--r-- | file.h | 1 | ||||
-rw-r--r-- | gtk/main_statusbar.c | 10 |
3 files changed, 30 insertions, 2 deletions
@@ -81,6 +81,7 @@ gboolean auto_scroll_live; static nstime_t first_ts; static nstime_t prev_dis_ts; static guint32 cum_bytes = 0; +static gulong computed_elapsed; static void cf_reset_state(capture_file *cf); @@ -410,6 +411,23 @@ void outofmemory_cb(gpointer dialog _U_, gint btn _U_, gpointer data _U_) main_window_exit(); } +gulong +cf_get_computed_elapsed(void){ + return computed_elapsed; +} +static void compute_elapsed(GTimeVal *start_time) +{ + gdouble delta_time; + GTimeVal time_now; + + g_get_current_time(&time_now); + + delta_time = (time_now.tv_sec - start_time->tv_sec) * 1e6 + + time_now.tv_usec - start_time->tv_usec; + + computed_elapsed = (gulong) (delta_time / 1000); /* ms*/ +} + cf_read_status_t cf_read(capture_file *cf) { @@ -596,6 +614,9 @@ cf_read(capture_file *cf) * don't need after the sequential run-through of the packets. */ postseq_cleanup_all_protocols(); + /* compute the time it took to load the file */ + compute_elapsed(&start_time); + /* Set the file encapsulation type now; we don't know what it is until we've looked at all the packets, as we don't know until then whether there's more than one type (and thus whether it's @@ -256,6 +256,7 @@ cf_status_t cf_filter_packets(capture_file *cf, gchar *dfilter, gboolean force); */ void cf_reftime_packets(capture_file *cf); +gulong cf_get_computed_elapsed(void); /** * At least one "Refence Time" flag has changed, rescan all packets. * diff --git a/gtk/main_statusbar.c b/gtk/main_statusbar.c index ce788e549a..87a0841774 100644 --- a/gtk/main_statusbar.c +++ b/gtk/main_statusbar.c @@ -368,6 +368,8 @@ void packets_bar_update(void) { +gulong computed_elapsed = cf_get_computed_elapsed(); + if(packets_bar) { /* remove old status */ if(packets_str) { @@ -381,8 +383,12 @@ packets_bar_update(void) packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u Dropped: %u", cfile.count, cfile.displayed_count, cfile.marked_count, cfile.drops); } else { - packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u", - cfile.count, cfile.displayed_count, cfile.marked_count); + packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u Time: %02lu:%02lu:%02lu.%03lu", + cfile.count, cfile.displayed_count, cfile.marked_count, + computed_elapsed/3600000, + computed_elapsed%3600000/60000, + computed_elapsed%60000/1000, + computed_elapsed%1000); } } else { packets_str = g_strdup(" No Packets"); |