net/bnxt: refactor init/uninit
[dpdk.git] / app / test-regex / main.c
index 2948d3e..aea4fa6 100644 (file)
@@ -48,6 +48,8 @@ struct qp_params {
        struct rte_regex_ops **ops;
        struct job_ctx *jobs_ctx;
        char *buf;
+       uint64_t start;
+       uint64_t cycles;
 };
 
 struct qps_per_lcore {
@@ -324,9 +326,7 @@ run_regex(void *args)
        unsigned long d_ind = 0;
        struct rte_mbuf_ext_shared_info shinfo;
        int res = 0;
-       time_t start;
-       time_t end;
-       double time;
+       long double time;
        struct rte_mempool *mbuf_mp;
        struct qp_params *qp;
        struct qp_params *qps = NULL;
@@ -418,9 +418,10 @@ run_regex(void *args)
 
                qp->buf = buf;
                qp->total_matches = 0;
+               qp->start = 0;
+               qp->cycles = 0;
        }
 
-       start = clock();
        for (i = 0; i < nb_iterations; i++) {
                for (qp_id = 0; qp_id < nb_qps; qp_id++) {
                        qp = &qps[qp_id];
@@ -432,6 +433,7 @@ run_regex(void *args)
                        for (qp_id = 0; qp_id < nb_qps; qp_id++) {
                                qp = &qps[qp_id];
                                if (qp->total_dequeue < actual_jobs) {
+                                       qp->start = rte_rdtsc_precise();
                                        struct rte_regex_ops **
                                                cur_ops_to_enqueue = qp->ops +
                                                qp->total_enqueue;
@@ -460,23 +462,28 @@ run_regex(void *args)
                                                        cur_ops_to_dequeue,
                                                        qp->total_enqueue -
                                                        qp->total_dequeue);
+                                       qp->cycles +=
+                                            (rte_rdtsc_precise() - qp->start);
                                        update = true;
                                }
                        }
                } while (update);
        }
-       end = clock();
-       time = ((double)end - start) / CLOCKS_PER_SEC;
-       printf("Job len = %ld Bytes\n",  job_len);
-       printf("Time = %lf sec\n",  time);
-       printf("Perf = %lf Gbps\n",
-              (((double)actual_jobs * job_len * nb_iterations * 8) / time) /
-               1000000000.0);
+       for (qp_id = 0; qp_id < nb_qps; qp_id++) {
+               qp = &qps[qp_id];
+               time = (long double)qp->cycles / rte_get_timer_hz();
+               printf("Core=%u QP=%u Job=%ld Bytes Time=%Lf sec Perf=%Lf "
+                      "Gbps\n", rte_lcore_id(), qp_id + qp_id_base,
+                      job_len, time,
+                      (((double)actual_jobs * job_len * nb_iterations * 8)
+                      / time) / 1000000000.0);
+       }
 
        if (rgxc->perf_mode)
                goto end;
        for (qp_id = 0; qp_id < nb_qps; qp_id++) {
-               printf("\n############ QP id=%u ############\n", qp_id);
+               printf("\n############ Core=%u QP=%u ############\n",
+                      rte_lcore_id(), qp_id + qp_id_base);
                qp = &qps[qp_id];
                /* Log results per job. */
                for (d_ind = 0; d_ind < qp->total_dequeue; d_ind++) {