1 /* service_response_time_table.c
2 * service_response_time_table 2003 Ronnie Sahlberg
3 * Helper routines common to all service response time statistics
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include "epan/packet_info.h"
34 #include "ui/simple_dialog.h"
35 #include "ui/utf8_entities.h"
37 #include "ui/gtk/service_response_time_table.h"
38 #include "ui/gtk/filter_utils.h"
39 #include "ui/gtk/gui_utils.h"
41 #define NANOSECS_PER_SEC 1000000000
56 srt_select_filter_cb(GtkWidget
*widget _U_
, gpointer callback_data
, guint callback_action
)
58 srt_stat_table
*rst
= (srt_stat_table
*)callback_data
;
62 GtkTreeSelection
*sel
;
65 if(rst
->filter_string
==NULL
){
69 sel
= gtk_tree_view_get_selection (GTK_TREE_VIEW(rst
->table
));
71 if (!gtk_tree_selection_get_selected(sel
, &model
, &iter
))
74 gtk_tree_model_get (model
, &iter
, INDEX_COLUMN
, &selection
, -1);
75 if(selection
>=(int)rst
->num_procs
){
76 simple_dialog(ESD_TYPE_ERROR
, ESD_BTN_OK
, "No procedure selected");
80 str
= g_strdup_printf("%s==%d", rst
->filter_string
, selection
);
82 apply_selected_filter (callback_action
, str
);
88 srt_show_popup_menu_cb(void *widg _U_
, GdkEvent
*event
, srt_stat_table
*rst
)
90 GdkEventButton
*bevent
= (GdkEventButton
*)event
;
92 if(event
->type
==GDK_BUTTON_PRESS
&& bevent
->button
==3){
93 gtk_menu_popup(GTK_MENU(rst
->menu
), NULL
, NULL
, NULL
, NULL
,
94 bevent
->button
, bevent
->time
);
101 /* Action callbacks */
103 apply_as_selected_cb(GtkWidget
*widget
, gpointer user_data
)
105 srt_select_filter_cb( widget
, user_data
, CALLBACK_MATCH(ACTYPE_SELECTED
, 0));
108 apply_as_not_selected_cb(GtkWidget
*widget
, gpointer user_data
)
110 srt_select_filter_cb( widget
, user_data
, CALLBACK_MATCH(ACTYPE_NOT_SELECTED
, 0));
113 apply_as_and_selected_cb(GtkWidget
*widget
, gpointer user_data
)
115 srt_select_filter_cb( widget
, user_data
, CALLBACK_MATCH(ACTYPE_AND_SELECTED
, 0));
118 apply_as_or_selected_cb(GtkWidget
*widget
, gpointer user_data
)
120 srt_select_filter_cb( widget
, user_data
, CALLBACK_MATCH(ACTYPE_OR_SELECTED
, 0));
123 apply_as_and_not_selected_cb(GtkWidget
*widget
, gpointer user_data
)
125 srt_select_filter_cb( widget
, user_data
, CALLBACK_MATCH(ACTYPE_AND_NOT_SELECTED
, 0));
128 apply_as_or_not_selected_cb(GtkWidget
*widget
, gpointer user_data
)
130 srt_select_filter_cb( widget
, user_data
, CALLBACK_MATCH(ACTYPE_OR_NOT_SELECTED
, 0));
134 prep_as_selected_cb(GtkWidget
*widget
, gpointer user_data
)
136 srt_select_filter_cb( widget
, user_data
, CALLBACK_PREPARE(ACTYPE_SELECTED
, 0));
139 prep_as_not_selected_cb(GtkWidget
*widget
, gpointer user_data
)
141 srt_select_filter_cb( widget
, user_data
, CALLBACK_PREPARE(ACTYPE_NOT_SELECTED
, 0));
144 prep_as_and_selected_cb(GtkWidget
*widget
, gpointer user_data
)
146 srt_select_filter_cb( widget
, user_data
, CALLBACK_PREPARE(ACTYPE_AND_SELECTED
, 0));
149 prep_as_or_selected_cb(GtkWidget
*widget
, gpointer user_data
)
151 srt_select_filter_cb( widget
, user_data
, CALLBACK_PREPARE(ACTYPE_OR_SELECTED
, 0));
154 prep_as_and_not_selected_cb(GtkWidget
*widget
, gpointer user_data
)
156 srt_select_filter_cb( widget
, user_data
, CALLBACK_PREPARE(ACTYPE_AND_NOT_SELECTED
, 0));
159 prep_as_or_not_selected_cb(GtkWidget
*widget
, gpointer user_data
)
161 srt_select_filter_cb( widget
, user_data
, CALLBACK_PREPARE(ACTYPE_OR_NOT_SELECTED
, 0));
165 find_selected_cb(GtkWidget
*widget
, gpointer user_data
)
167 srt_select_filter_cb( widget
, user_data
, CALLBACK_FIND_FRAME(ACTYPE_SELECTED
, 0));
170 find_not_selected_cb(GtkWidget
*widget
, gpointer user_data
)
172 srt_select_filter_cb( widget
, user_data
, CALLBACK_FIND_FRAME(ACTYPE_NOT_SELECTED
, 0));
175 find_prev_selected_cb(GtkWidget
*widget
, gpointer user_data
)
177 srt_select_filter_cb( widget
, user_data
, CALLBACK_FIND_PREVIOUS(ACTYPE_SELECTED
, 0));
180 find_prev_not_selected_cb(GtkWidget
*widget
, gpointer user_data
)
182 srt_select_filter_cb( widget
, user_data
, CALLBACK_FIND_PREVIOUS(ACTYPE_NOT_SELECTED
, 0));
185 find_next_selected_cb(GtkWidget
*widget
, gpointer user_data
)
187 srt_select_filter_cb( widget
, user_data
, CALLBACK_FIND_NEXT(ACTYPE_SELECTED
, 0));
190 find_next_not_selected_cb(GtkWidget
*widget
, gpointer user_data
)
192 srt_select_filter_cb( widget
, user_data
, CALLBACK_FIND_NEXT(ACTYPE_NOT_SELECTED
, 0));
195 color_selected_cb(GtkWidget
*widget
, gpointer user_data
)
197 srt_select_filter_cb( widget
, user_data
, CALLBACK_COLORIZE(ACTYPE_SELECTED
, 0));
200 color_not_selected_cb(GtkWidget
*widget
, gpointer user_data
)
202 srt_select_filter_cb( widget
, user_data
, CALLBACK_COLORIZE(ACTYPE_SELECTED
, 0));
205 static const char *ui_desc_service_resp_t_filter_popup
=
207 " <popup name='ServiceRespTFilterPopup'>\n"
208 " <menu action='/Apply as Filter'>\n"
209 " <menuitem action='/Apply as Filter/Selected'/>\n"
210 " <menuitem action='/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS
" not Selected'/>\n"
211 " <menuitem action='/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS
" and Selected'/>\n"
212 " <menuitem action='/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS
" or Selected'/>\n"
213 " <menuitem action='/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS
" and not Selected'/>\n"
214 " <menuitem action='/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS
" or not Selected'/>\n"
216 " <menu action='/Prepare a Filter'>\n"
217 " <menuitem action='/Prepare a Filter/Selected'/>\n"
218 " <menuitem action='/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS
" not Selected'/>\n"
219 " <menuitem action='/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS
" and Selected'/>\n"
220 " <menuitem action='/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS
" or Selected'/>\n"
221 " <menuitem action='/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS
" and not Selected'/>\n"
222 " <menuitem action='/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS
" or not Selected'/>\n"
224 " <menu action='/Find Frame'>\n"
225 " <menu action='/Find Frame/Find Frame'>\n"
226 " <menuitem action='/Find Frame/Selected'/>\n"
227 " <menuitem action='/Find Frame/Not Selected'/>\n"
229 " <menu action='/Find Frame/Find Next'>\n"
230 " <menuitem action='/Find Next/Selected'/>\n"
231 " <menuitem action='/Find Next/Not Selected'/>\n"
233 " <menu action='/Find Frame/Find Previous'>\n"
234 " <menuitem action='/Find Previous/Selected'/>\n"
235 " <menuitem action='/Find Previous/Not Selected'/>\n"
238 " <menu action='/Colorize Procedure'>\n"
239 " <menuitem action='/Colorize Procedure/Selected'/>\n"
240 " <menuitem action='/Colorize Procedure/Not Selected'/>\n"
249 * const gchar *stock_id;
250 * const gchar *label;
251 * const gchar *accelerator;
252 * const gchar *tooltip;
253 * GCallback callback;
255 * const gchar *name; The name of the action.
256 * const gchar *stock_id; The stock id for the action, or the name of an icon from the icon theme.
257 * const gchar *label; The label for the action. This field should typically be marked for translation,
258 * see gtk_action_group_set_translation_domain().
259 * If label is NULL, the label of the stock item with id stock_id is used.
260 * const gchar *accelerator; The accelerator for the action, in the format understood by gtk_accelerator_parse().
261 * const gchar *tooltip; The tooltip for the action. This field should typically be marked for translation,
262 * see gtk_action_group_set_translation_domain().
263 * GCallback callback; The function to call when the action is activated.
266 static const GtkActionEntry service_resp_t__popup_entries
[] = {
267 { "/Apply as Filter", NULL
, "Apply as Filter", NULL
, NULL
, NULL
},
268 { "/Prepare a Filter", NULL
, "Prepare a Filter", NULL
, NULL
, NULL
},
269 { "/Find Frame", NULL
, "Find Frame", NULL
, NULL
, NULL
},
270 { "/Find Frame/Find Frame", NULL
, "Find Frame", NULL
, NULL
, NULL
},
271 { "/Find Frame/Find Next", NULL
, "Find Next" , NULL
, NULL
, NULL
},
272 { "/Find Frame/Find Previous", NULL
, "Find Previous", NULL
, NULL
, NULL
},
273 { "/Colorize Procedure", NULL
, "Colorize Procedure", NULL
, NULL
, NULL
},
274 { "/Apply as Filter/Selected", NULL
, "Selected", NULL
, "Selected", G_CALLBACK(apply_as_selected_cb
) },
275 { "/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS
" not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" not Selected", G_CALLBACK(apply_as_not_selected_cb
) },
276 { "/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS
" and Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" and Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" and Selected", G_CALLBACK(apply_as_and_selected_cb
) },
277 { "/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS
" or Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" or Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" or Selected", G_CALLBACK(apply_as_or_selected_cb
) },
278 { "/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS
" and not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" and not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" and not Selected", G_CALLBACK(apply_as_and_not_selected_cb
) },
279 { "/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS
" or not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" or not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" or not Selected", G_CALLBACK(apply_as_or_not_selected_cb
) },
280 { "/Prepare a Filter/Selected", NULL
, "Selected", NULL
, "selcted", G_CALLBACK(prep_as_selected_cb
) },
281 { "/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS
" not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" not Selected", G_CALLBACK(prep_as_not_selected_cb
) },
282 { "/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS
" and Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" and Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" and Selected", G_CALLBACK(prep_as_and_selected_cb
) },
283 { "/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS
" or Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" or Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" or Selected", G_CALLBACK(prep_as_or_selected_cb
) },
284 { "/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS
" and not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" and not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" and not Selected", G_CALLBACK(prep_as_and_not_selected_cb
) },
285 { "/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS
" or not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" or not Selected", NULL
, UTF8_HORIZONTAL_ELLIPSIS
" or not Selected", G_CALLBACK(prep_as_or_not_selected_cb
) },
286 { "/Find Frame/Selected", NULL
, "Selected", NULL
, "Selected", G_CALLBACK(find_selected_cb
) },
287 { "/Find Frame/Not Selected", NULL
, "Not Selected", NULL
, "Not Selected", G_CALLBACK(find_not_selected_cb
) },
288 { "/Find Previous/Selected", NULL
, "Selected", NULL
, "Selected", G_CALLBACK(find_prev_selected_cb
) },
289 { "/Find Previous/Not Selected", NULL
, "Not Selected", NULL
, "Not Selected", G_CALLBACK(find_prev_not_selected_cb
) },
290 { "/Find Next/Selected", NULL
, "Selected", NULL
, "Selected", G_CALLBACK(find_next_selected_cb
) },
291 { "/Find Next/Not Selected", NULL
, "Not Selected", NULL
, "Not Selected", G_CALLBACK(find_next_not_selected_cb
) },
292 { "/Colorize Procedure/Selected", NULL
, "Selected", NULL
, "Selected", G_CALLBACK(color_selected_cb
) },
293 { "/Colorize Procedure/Not Selected", NULL
, "Not Selected", NULL
, "Not Selected", G_CALLBACK(color_not_selected_cb
) },
297 srt_create_popup_menu(srt_stat_table
*rst
)
299 GtkUIManager
*ui_manager
;
300 GtkActionGroup
*action_group
;
301 GError
*error
= NULL
;
303 action_group
= gtk_action_group_new ("ServiceRespTFilterPopupActionGroup");
304 gtk_action_group_add_actions (action_group
, /* the action group */
305 (GtkActionEntry
*)service_resp_t__popup_entries
, /* an array of action descriptions */
306 G_N_ELEMENTS(service_resp_t__popup_entries
), /* the number of entries */
307 rst
); /* data to pass to the action callbacks */
309 ui_manager
= gtk_ui_manager_new ();
310 gtk_ui_manager_insert_action_group (ui_manager
,
312 0); /* the position at which the group will be inserted */
313 gtk_ui_manager_add_ui_from_string (ui_manager
,ui_desc_service_resp_t_filter_popup
, -1, &error
);
316 fprintf (stderr
, "Warning: building service response time filter popup failed: %s\n",
318 g_error_free (error
);
321 rst
->menu
= gtk_ui_manager_get_widget(ui_manager
, "/ServiceRespTFilterPopup");
322 g_signal_connect(rst
->table
, "button_press_event", G_CALLBACK(srt_show_popup_menu_cb
), rst
);
326 /* ---------------- */
328 srt_time_func (GtkTreeViewColumn
*column _U_
,
329 GtkCellRenderer
*renderer
,
337 /* The col to get data from is in userdata */
338 gint data_column
= GPOINTER_TO_INT(user_data
);
340 gtk_tree_model_get(model
, iter
, data_column
, &data
, -1);
342 g_object_set(renderer
, "text", "", NULL
);
345 str
= g_strdup_printf("%3d.%06d", (int)data
->secs
, (data
->nsecs
+500)/1000);
346 g_object_set(renderer
, "text", str
, NULL
);
351 srt_avg_func (GtkTreeViewColumn
*column _U_
,
352 GtkCellRenderer
*renderer
,
359 gint data_column
= GPOINTER_TO_INT(user_data
);
361 gtk_tree_model_get(model
, iter
, data_column
, &td
, -1);
362 str
=g_strdup_printf("%3d.%06d",
363 (int)(td
/1000000), (int)(td
%1000000));
364 g_object_set(renderer
, "text", str
, NULL
);
369 srt_time_sort_func(GtkTreeModel
*model
,
377 gint data_column
= GPOINTER_TO_INT(user_data
);
379 gtk_tree_model_get(model
, a
, data_column
, &ns_a
, -1);
380 gtk_tree_model_get(model
, b
, data_column
, &ns_b
, -1);
385 else if (ns_a
== NULL
|| ns_b
== NULL
) {
386 ret
= (ns_a
== NULL
) ? -1 : 1;
389 ret
= nstime_cmp(ns_a
,ns_b
);
395 XXX Resizable columns are ugly when there's more than on table cf. SMB
398 init_srt_table(srt_stat_table
*rst
, int num_procs
, GtkWidget
*vbox
, const char *filter_string
)
403 GtkTreeViewColumn
*column
;
404 GtkCellRenderer
*renderer
;
405 GtkTreeSortable
*sortable
;
406 GtkTreeSelection
*sel
;
408 static const char *default_titles
[] = { "Index", "Procedure", "Calls", "Min SRT", "Max SRT", "Avg SRT" };
410 /* Create the store */
411 store
= gtk_list_store_new (N_COLUMNS
, /* Total number of columns */
412 G_TYPE_INT
, /* Index */
413 G_TYPE_STRING
, /* Procedure */
414 G_TYPE_UINT
, /* Calls */
415 G_TYPE_POINTER
, /* Min SRT */
416 G_TYPE_POINTER
, /* Max SRT */
417 G_TYPE_UINT64
); /* Avg SRT */
420 tree
= gtk_tree_view_new_with_model (GTK_TREE_MODEL (store
));
421 rst
->table
= GTK_TREE_VIEW(tree
);
422 sortable
= GTK_TREE_SORTABLE(store
);
424 /* The view now holds a reference. We can get rid of our own reference */
425 g_object_unref (G_OBJECT (store
));
428 rst
->filter_string
=g_strdup(filter_string
);
430 rst
->filter_string
=NULL
;
432 for (i
= 0; i
< N_COLUMNS
; i
++) {
433 renderer
= gtk_cell_renderer_text_new ();
434 if (i
!= PROCEDURE_COLUMN
) {
435 /* right align numbers */
436 g_object_set(G_OBJECT(renderer
), "xalign", 1.0, NULL
);
438 g_object_set(renderer
, "ypad", 0, NULL
);
442 column
= gtk_tree_view_column_new_with_attributes (default_titles
[i
], renderer
, NULL
);
443 gtk_tree_view_column_set_cell_data_func(column
, renderer
, srt_time_func
, GINT_TO_POINTER(i
), NULL
);
444 gtk_tree_sortable_set_sort_func(sortable
, i
, srt_time_sort_func
, GINT_TO_POINTER(i
), NULL
);
447 column
= gtk_tree_view_column_new_with_attributes (default_titles
[i
], renderer
, NULL
);
448 gtk_tree_view_column_set_cell_data_func(column
, renderer
, srt_avg_func
, GINT_TO_POINTER(i
), NULL
);
451 column
= gtk_tree_view_column_new_with_attributes (default_titles
[i
], renderer
, "text",
456 gtk_tree_view_column_set_sort_column_id(column
, i
);
457 gtk_tree_view_column_set_resizable(column
, TRUE
);
458 gtk_tree_view_append_column (rst
->table
, column
);
459 if (i
== CALLS_COLUMN
) {
460 /* XXX revert order sort */
461 gtk_tree_view_column_clicked(column
);
462 gtk_tree_view_column_clicked(column
);
466 rst
->scrolled_window
=scrolled_window_new(NULL
, NULL
);
467 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(rst
->scrolled_window
),
469 gtk_container_add(GTK_CONTAINER(rst
->scrolled_window
), GTK_WIDGET (rst
->table
));
470 gtk_box_pack_start(GTK_BOX(vbox
), rst
->scrolled_window
, TRUE
, TRUE
, 0);
472 gtk_tree_view_set_reorderable (rst
->table
, FALSE
);
473 /* Now enable the sorting of each column */
474 gtk_tree_view_set_rules_hint(rst
->table
, TRUE
);
475 gtk_tree_view_set_headers_clickable(rst
->table
, TRUE
);
477 gtk_widget_show(rst
->scrolled_window
);
479 rst
->num_procs
=num_procs
;
480 rst
->procedures
=(srt_procedure_t
*)g_malloc(sizeof(srt_procedure_t
)*num_procs
);
481 for(i
=0;i
<num_procs
;i
++){
482 time_stat_init(&rst
->procedures
[i
].stats
);
483 rst
->procedures
[i
].index
= 0;
484 rst
->procedures
[i
].procedure
= NULL
;
487 sel
= gtk_tree_view_get_selection(GTK_TREE_VIEW(rst
->table
));
488 gtk_tree_selection_set_mode(sel
, GTK_SELECTION_SINGLE
);
489 /* create popup menu for this table */
490 if(rst
->filter_string
){
491 srt_create_popup_menu(rst
);
496 init_srt_table_row(srt_stat_table
*rst
, int indx
, const char *procedure
)
498 /* we have discovered a new procedure. Extend the table accordingly */
499 if(indx
>=rst
->num_procs
){
500 int old_num_procs
=rst
->num_procs
;
503 rst
->num_procs
=indx
+1;
504 rst
->procedures
=(srt_procedure_t
*)g_realloc(rst
->procedures
, sizeof(srt_procedure_t
)*(rst
->num_procs
));
505 for(i
=old_num_procs
;i
<rst
->num_procs
;i
++){
506 time_stat_init(&rst
->procedures
[i
].stats
);
507 rst
->procedures
[i
].index
= i
;
508 rst
->procedures
[i
].procedure
=NULL
;
511 rst
->procedures
[indx
].index
= indx
;
512 rst
->procedures
[indx
].procedure
=g_strdup(procedure
);
516 add_srt_table_data(srt_stat_table
*rst
, int indx
, const nstime_t
*req_time
, packet_info
*pinfo
)
521 g_assert(indx
>= 0 && indx
< rst
->num_procs
);
522 rp
=&rst
->procedures
[indx
];
525 * If the count of calls for this procedure is currently zero, it's
526 * going to become non-zero, so add a row for it (we don't want
527 * rows for procedures that have no calls - especially if the
528 * procedure has no calls because the index doesn't correspond
529 * to a procedure, but is an unused/reserved value).
531 * (Yes, this means that the rows aren't in order by anything
532 * interesting. That's why we have the table sorted by a column.)
535 if (rp
->stats
.num
==0){
536 GtkListStore
*store
= GTK_LIST_STORE(gtk_tree_view_get_model(rst
->table
));
537 gtk_list_store_append(store
, &rp
->iter
);
538 gtk_list_store_set(store
, &rp
->iter
,
539 INDEX_COLUMN
, rp
->index
,
540 PROCEDURE_COLUMN
, rp
->procedure
,
541 CALLS_COLUMN
, rp
->stats
.num
,
542 MIN_SRT_COLUMN
, NULL
,
543 MAX_SRT_COLUMN
, NULL
,
544 AVG_SRT_COLUMN
, (guint64
)0,
548 /* calculate time delta between request and reply */
550 nstime_delta(&delta
, &t
, req_time
);
552 time_stat_update(&rp
->stats
, &delta
, pinfo
);
556 draw_srt_table_data(srt_stat_table
*rst
)
560 GtkListStore
*store
= GTK_LIST_STORE(gtk_tree_view_get_model(rst
->table
));
562 for(i
=0;i
<rst
->num_procs
;i
++){
563 /* ignore procedures with no calls (they don't have rows) */
564 if(rst
->procedures
[i
].stats
.num
==0){
567 /* Scale the average SRT in units of 1us and round to the nearest us.
568 tot.secs is a time_t which may be 32 or 64 bits (or even floating)
569 depending uon the platform. After casting tot.secs to 64 bits, it
570 would take a capture with a duration of over 136 *years* to
571 overflow the secs portion of td. */
572 td
= ((guint64
)(rst
->procedures
[i
].stats
.tot
.secs
))*NANOSECS_PER_SEC
+ rst
->procedures
[i
].stats
.tot
.nsecs
;
573 td
= ((td
/ rst
->procedures
[i
].stats
.num
) + 500) / 1000;
575 gtk_list_store_set(store
, &rst
->procedures
[i
].iter
,
576 CALLS_COLUMN
, rst
->procedures
[i
].stats
.num
,
577 MIN_SRT_COLUMN
, &rst
->procedures
[i
].stats
.min
,
578 MAX_SRT_COLUMN
, &rst
->procedures
[i
].stats
.max
,
586 reset_srt_table_data(srt_stat_table
*rst
)
591 for(i
=0;i
<rst
->num_procs
;i
++){
592 time_stat_init(&rst
->procedures
[i
].stats
);
594 store
= GTK_LIST_STORE(gtk_tree_view_get_model(rst
->table
));
595 gtk_list_store_clear(store
);
599 free_srt_table_data(srt_stat_table
*rst
)
603 for(i
=0;i
<rst
->num_procs
;i
++){
604 g_free(rst
->procedures
[i
].procedure
);
605 rst
->procedures
[i
].procedure
=NULL
;
607 g_free(rst
->filter_string
);
608 rst
->filter_string
=NULL
;
609 g_free(rst
->procedures
);
610 rst
->procedures
=NULL
;