Compute the loading time and show it in the main status bar.

(Modified code from Didier Gautheron).

svn path=/trunk/; revision=29592
This commit is contained in:
Anders Broman 2009-08-28 05:19:52 +00:00
parent 5cba22a89b
commit 2cd2eecd0a
3 changed files with 30 additions and 2 deletions

21
file.c
View File

@ -81,6 +81,7 @@ gboolean auto_scroll_live;
static nstime_t first_ts; static nstime_t first_ts;
static nstime_t prev_dis_ts; static nstime_t prev_dis_ts;
static guint32 cum_bytes = 0; static guint32 cum_bytes = 0;
static gulong computed_elapsed;
static void cf_reset_state(capture_file *cf); 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(); 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_status_t
cf_read(capture_file *cf) 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. */ * don't need after the sequential run-through of the packets. */
postseq_cleanup_all_protocols(); 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 /* 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 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 there's more than one type (and thus whether it's

1
file.h
View File

@ -256,6 +256,7 @@ cf_status_t cf_filter_packets(capture_file *cf, gchar *dfilter, gboolean force);
*/ */
void cf_reftime_packets(capture_file *cf); void cf_reftime_packets(capture_file *cf);
gulong cf_get_computed_elapsed(void);
/** /**
* At least one "Refence Time" flag has changed, rescan all packets. * At least one "Refence Time" flag has changed, rescan all packets.
* *

View File

@ -368,6 +368,8 @@ void
packets_bar_update(void) packets_bar_update(void)
{ {
gulong computed_elapsed = cf_get_computed_elapsed();
if(packets_bar) { if(packets_bar) {
/* remove old status */ /* remove old status */
if(packets_str) { if(packets_str) {
@ -381,8 +383,12 @@ packets_bar_update(void)
packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u Dropped: %u", packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u Dropped: %u",
cfile.count, cfile.displayed_count, cfile.marked_count, cfile.drops); cfile.count, cfile.displayed_count, cfile.marked_count, cfile.drops);
} else { } else {
packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u", packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u Time: %02lu:%02lu:%02lu.%03lu",
cfile.count, cfile.displayed_count, cfile.marked_count); cfile.count, cfile.displayed_count, cfile.marked_count,
computed_elapsed/3600000,
computed_elapsed%3600000/60000,
computed_elapsed%60000/1000,
computed_elapsed%1000);
} }
} else { } else {
packets_str = g_strdup(" No Packets"); packets_str = g_strdup(" No Packets");