From 25c84d86d722a689ad592f6e10b0134be8a5bb39 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 9 Jan 2019 19:27:10 -0500 Subject: [PATCH] sharpd: Do addition/subtraction for me Write a bit of code to track the start/stop times and do subtraction! In the future we expect this code to slice and dice as well. Signed-off-by: Donald Sharp --- sharpd/sharp_zebra.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 8d6260494b..c9f333e34b 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -129,6 +129,8 @@ static int interface_state_down(int command, struct zclient *zclient, return 0; } +static struct timeval t_start; +static struct timeval t_end; extern uint32_t total_routes; extern uint32_t installed_routes; extern uint32_t removed_routes; @@ -152,6 +154,7 @@ void sharp_install_routes_helper(struct prefix *p, uint8_t instance, } else temp = ntohl(p->u.val32[3]); + monotime(&t_start); for (i = 0; i < routes; i++) { route_add(p, (uint8_t)instance, nhg); if (v4) @@ -175,6 +178,7 @@ void sharp_remove_routes_helper(struct prefix *p, uint8_t instance, } else temp = ntohl(p->u.val32[3]); + monotime(&t_start); for (i = 0; i < routes; i++) { route_delete(p, (uint8_t)instance); if (v4) @@ -207,6 +211,7 @@ static void handle_repeated(bool installed) static int route_notify_owner(int command, struct zclient *zclient, zebra_size_t length, vrf_id_t vrf_id) { + struct timeval r; struct prefix p; enum zapi_route_notify_owner note; uint32_t table; @@ -218,7 +223,10 @@ static int route_notify_owner(int command, struct zclient *zclient, case ZAPI_ROUTE_INSTALLED: installed_routes++; if (total_routes == installed_routes) { - zlog_debug("Installed All Items"); + monotime(&t_end); + timersub(&t_end, &t_start, &r); + zlog_debug("Installed All Items %ld.%ld", r.tv_sec, + r.tv_usec); handle_repeated(true); } break; @@ -231,7 +239,10 @@ static int route_notify_owner(int command, struct zclient *zclient, case ZAPI_ROUTE_REMOVED: removed_routes++; if (total_routes == removed_routes) { - zlog_debug("Removed all Items"); + monotime(&t_end); + timersub(&t_end, &t_start, &r); + zlog_debug("Removed all Items %ld.%ld", r.tv_sec, + r.tv_usec); handle_repeated(false); } break; -- 2.39.5