+ clib_bitmap_alloc (active, vec_len (nodes));
+ clib_bitmap_set_region (active, 0, 1, vec_len (nodes));
+ if (filter)
+ {
+ /*Adding the legend to the dot file*/
+ format__ (vm, fd, "%s",
+ " rankdir=\"LR\"\n nodesep=2\n subgraph cluster_legend {\n "
+ " label=\"Legend\"\n style=\"solid\"\n labelloc = b\n "
+ " subgraph cluster_colors {\n label=\"Packets/Call\"\n "
+ " style=\"solid\"\n labelloc = b\n");
+ format__ (vm, fd, "%s",
+ " 0 [label=\"No packet\", fixedsize=true shape=circle "
+ "width=2 fontsize=17]\n"
+ " 1 [label=\"1-32\", fillcolor=1 style=filled "
+ "colorscheme=ylorrd8 fixedsize=true shape=circle width=2 "
+ "fontsize=17]\n"
+ " 2 [label=\"33-64\", fillcolor=2 style=filled "
+ "colorscheme=ylorrd8 fixedsize=true shape=circle width=2 "
+ "fontsize=17]\n"
+ " 3 [label=\"65-96\", fillcolor=3 style=filled "
+ "colorscheme=ylorrd8 fixedsize=true shape=circle width=2 "
+ "fontsize=17]\n"
+ " 4 [label=\"97-128\", fillcolor=4 style=filled "
+ "colorscheme=ylorrd8 fixedsize=true shape=circle width=2 "
+ "fontsize=17]\n"
+ " 5 [label=\"129-160\", fillcolor=5 style=filled "
+ "colorscheme=ylorrd8 fixedsize=true shape=circle width=2 "
+ "fontsize=17]\n"
+ " 6 [label=\"161-192\", fillcolor=6 style=filled "
+ "colorscheme=ylorrd8 fixedsize=true shape=circle width=2 "
+ "fontsize=17]\n"
+ " 7 [label=\"193-224\", fillcolor=7 style=filled "
+ "colorscheme=ylorrd8 fixedsize=true shape=circle width=2 "
+ "fontsize=17]\n"
+ " 8 [label=\"224+\", fillcolor=8 style=filled "
+ "colorscheme=ylorrd8 fixedsize=true shape=circle width=2 "
+ "fontsize=17]\n");
+ format__ (vm, fd, "%s",
+ " 0 -> 1 -> 2 -> 3 -> 4 [style=\"invis\",weight =100]\n "
+ " 5 -> 6 -> 7 -> 8 [style=\"invis\",weight =100]\n }\n "
+ " subgraph cluster_size {\n label=\"Cycles/Packet\"\n "
+ " style=\"solid\"\n labelloc = b\n");
+ format__ (
+ vm, fd, "%s",
+ " a[label=\"0\",fixedsize=true shape=circle width=1] \n"
+ " b[label=\"10\",fixedsize=true shape=circle width=2 "
+ "fontsize=17]\n"
+ " c[label=\"100\",fixedsize=true shape=circle width=3 "
+ "fontsize=20]\n"
+ " d[label=\"1000\",fixedsize=true shape=circle width=4 "
+ "fontsize=23]\n"
+ " a -> b -> c -> d [style=\"invis\",weight =100]\n }\n }\n");
+
+ vlib_worker_thread_barrier_sync (vm);
+ for (j = 0; j < vec_len (nm->nodes); j++)
+ {
+ vlib_node_t *n;
+ n = nm->nodes[j];
+ vlib_node_sync_stats (vm, n);
+ }
+
+ /* Updating the stats for multithreaded use cases.
+ * We need to dup the nodes to sum the stats from all threads.*/
+ nodes = vec_dup (nm->nodes);
+ for (i = 1; i < vlib_get_n_threads (); i++)
+ {
+ vlib_node_main_t *nm_clone;
+ vlib_main_t *vm_clone;
+ vlib_node_runtime_t *rt;
+ vlib_node_t *n;
+
+ vm_clone = vlib_get_main_by_index (i);
+ nm_clone = &vm_clone->node_main;
+
+ for (j = 0; j < vec_len (nm_clone->nodes); j++)
+ {
+ n = nm_clone->nodes[j];
+
+ rt = vlib_node_get_runtime (vm_clone, n->index);
+ /* Sync the stats directly in the duplicated node.*/
+ vlib_node_runtime_sync_stats_node (nodes[j], rt, 0, 0, 0);
+ }
+ }
+ vlib_worker_thread_barrier_release (vm);
+
+ for (i = 0; i < vec_len (nodes); i++)
+ {
+ u64 p, c, l;
+ c = nodes[i]->stats_total.calls - nodes[i]->stats_last_clear.calls;
+ p =
+ nodes[i]->stats_total.vectors - nodes[i]->stats_last_clear.vectors;
+ l = nodes[i]->stats_total.clocks - nodes[i]->stats_last_clear.clocks;
+
+ if ((both && c > 0 && p > 0) || (calls_filter && c > 0) ||
+ (vectors_filter && p > 0))
+ {
+ format__ (vm, fd, " \"%v\" [shape=circle", nodes[i]->name);
+ /*Changing the size and the font of nodes that receive packets*/
+ if (p > 0)
+ {
+ f64 x = (f64) l / (f64) p;
+ f64 size_ratio = (1 + log10 (x + 1));
+ format__ (vm, fd, " width=%.2f fontsize=%.2f fixedsize=true",
+ size_ratio, 11 + 3 * size_ratio);
+ /*Coloring nodes that are indeed called*/
+ if (c > 0)
+ {
+ u64 color = ((p - 1) / (32 * c)) + 1;
+ color = clib_min (color, 8);
+ format__ (
+ vm, fd,
+ " fillcolor=%u style=filled colorscheme=ylorrd8",
+ color);
+ }
+ }
+ format__ (vm, fd, "]\n");
+ }
+ else
+ {
+ clib_bitmap_set (active, i, 0);
+ }
+ }
+ }