zoukankan      html  css  js  c++  java
  • DPDK latencystats库使用方案

    初始化

    注意务必调用 

    rte_metrics_init
        /* init latency stats */
        /* @TODO should we remove this in product env? */
        rte_metrics_init(numa);
        if (rte_latencystats_init(1, NULL)) {
    	printf("Could not allocate latency data,
    ");
        }
    

    update

    /* 这个函数周期调用,比如1s调用一次,会更新latency数据并打印出之前的统计值 */   

    static void print_latency(void) { struct rte_metric_value * metrics; struct rte_metric_value * metrics; struct rte_metric_name * names; int len ; int ret; int i,j; len = 4; /* rte_metrics_get_names(NULL, 0); // 这里仅仅用来获取个数,为后续申请内存使用,若已固定知道则可以忽略。 if (len <= 0) { printf("Get metrics count: %d error ", len); return; }*/ metrics = malloc(sizeof(struct rte_metric_value) * len); names = malloc(sizeof(struct rte_metric_name) * len); if (metrics == NULL || names == NULL) { printf("Cannot allocate memory "); free(metrics); free(names); return; } len = rte_metrics_get_names(names,len); if (len <= 0) { printf("Get metrics name: %d error ", len); return; } for(j = 0; j < 2; j++) { ret = rte_metrics_get_values(j, metrics, len); if (ret < 0 || ret > len) { printf("Cannot get metrics values "); free(metrics); free(names); return; } PAL_LOG("Metrics for port %d: ", j); for (i = 0; i < len; i++) printf(" %s: %"PRIu64" ",names[metrics[i].key].name, metrics[i].value); } free(metrics); free(names); rte_latencystats_update(); }

      

  • 相关阅读:
    BZOJ 1009 GT考试
    BZOJ 2085 [POI2010] Hamsters
    BZOJ 3160 万径人踪灭
    左偏树 / 非旋转treap学习笔记
    BZOJ 3217 ALOEXT
    BZOJ 3065 带插入区间第K小值
    BZOJ2716 天使玩偶
    XSY1659 [HNOI2012]永无乡
    BZOJ1367【Baltic2004】sequence
    蔡勒公式 计算星期
  • 原文地址:https://www.cnblogs.com/lovemyspring/p/11232134.html
Copyright © 2011-2022 走看看