+
+ if (sm->serialized_nodes)
+ {
+ nodes_by_thread = vlib_node_unserialize (sm->serialized_nodes);
+
+ /* Across all threads... */
+ for (i = 0; i < vec_len (nodes_by_thread); i++)
+ {
+ u64 n_input, n_output, n_drop, n_punt;
+ u64 n_internal_vectors, n_internal_calls;
+ u64 n_clocks, l, v, c;
+ f64 dt;
+
+ nodes = nodes_by_thread[i];
+
+ fformat (stdout, "Thread %d -------------------------\n", i);
+
+ n_input = n_output = n_drop = n_punt = n_clocks = 0;
+ n_internal_vectors = n_internal_calls = 0;
+
+ /* Across all nodes */
+ for (j = 0; j < vec_len (nodes); j++)
+ {
+ n = nodes[j];
+
+ /* Exactly stolen from node_cli.c... */
+ l = n->stats_total.clocks - n->stats_last_clear.clocks;
+ n_clocks += l;
+
+ v = n->stats_total.vectors - n->stats_last_clear.vectors;
+ c = n->stats_total.calls - n->stats_last_clear.calls;
+
+ switch (n->type)
+ {
+ default:
+ continue;
+
+ case VLIB_NODE_TYPE_INTERNAL:
+ n_output +=
+ (n->flags & VLIB_NODE_FLAG_IS_OUTPUT) ? v : 0;
+ n_drop += (n->flags & VLIB_NODE_FLAG_IS_DROP) ? v : 0;
+ n_punt += (n->flags & VLIB_NODE_FLAG_IS_PUNT) ? v : 0;
+ if (!(n->flags & VLIB_NODE_FLAG_IS_OUTPUT))
+ {
+ n_internal_vectors += v;
+ n_internal_calls += c;
+ }
+ if (n->flags & VLIB_NODE_FLAG_IS_HANDOFF)
+ n_input += v;
+ break;
+
+ case VLIB_NODE_TYPE_INPUT:
+ n_input += v;
+ break;
+ }
+
+ if (n->stats_total.calls)
+ {
+ fformat (stdout,
+ "%s (%s): clocks %lld calls %lld vectors %lld ",
+ n->name,
+ n->state_string,
+ n->stats_total.clocks,
+ n->stats_total.calls, n->stats_total.vectors);
+ if (n->stats_total.vectors)
+ fformat (stdout, "clocks/pkt %.2f\n",
+ (f64) n->stats_total.clocks /
+ (f64) n->stats_total.vectors);
+ else
+ fformat (stdout, "\n");
+ }
+ vec_free (n->name);
+ vec_free (n->next_nodes);
+ vec_free (n);
+ }
+
+ fformat (stdout, "average vectors/node %.2f\n",
+ (n_internal_calls > 0
+ ? (f64) n_internal_vectors / (f64) n_internal_calls
+ : 0));
+
+
+ dt = *sm->last_runtime_ptr - *sm->last_runtime_stats_clear_ptr;
+
+ fformat (stdout,
+ " vectors rates in %.4e, out %.4e, drop %.4e, "
+ "punt %.4e\n",
+ (f64) n_input / dt,
+ (f64) n_output / dt, (f64) n_drop / dt,
+ (f64) n_punt / dt);
+
+ vec_free (nodes);
+ }
+ vec_free (nodes_by_thread);
+ }
+ else
+ {
+ fformat (stdout, "serialized nodes NULL?\n");
+ }
+