diff mbox

[API-NEXT,2/4] test/example: avoid "cycle" word usage

Message ID 1438808473-26968-3-git-send-email-ivan.khoronzhuk@linaro.org
State New
Headers show

Commit Message

Ivan Khoronzhuk Aug. 5, 2015, 9:01 p.m. UTC
The word "cycle" is left from old API time names. The "cycle" is
ambiguous word, especially when it can be used with software cycles.
So better to use "time" word or just "t" symbol, as no matter in
which units time is measured, in sec, hours, cycles or counts.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 example/ipsec/odp_ipsec.c             | 14 +++---
 example/timer/odp_timer_test.c        | 22 +++++-----
 test/performance/odp_pktio_perf.c     | 38 ++++++++--------
 test/performance/odp_scheduling.c     | 82 +++++++++++++++++------------------
 test/validation/scheduler/scheduler.c |  4 +-
 test/validation/time/time.c           | 38 ++++++++--------
 6 files changed, 99 insertions(+), 99 deletions(-)
diff mbox

Patch

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 8a18322..f431e53 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -265,11 +265,11 @@  odp_queue_t polled_odp_queue_create(const char *name,
 static
 odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait)
 {
-	uint64_t start_cycle;
-	uint64_t cycle;
+	uint64_t start_time;
+	uint64_t time;
 	uint64_t diff;
 
-	start_cycle = 0;
+	start_time = 0;
 
 	while (1) {
 		int idx;
@@ -292,13 +292,13 @@  odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait)
 		if (ODP_SCHED_NO_WAIT == wait)
 			break;
 
-		if (0 == start_cycle) {
-			start_cycle = odp_time_counts();
+		if (0 == start_time) {
+			start_time = odp_time_counts();
 			continue;
 		}
 
-		cycle = odp_time_counts();
-		diff  = odp_time_diff_counts(start_cycle, cycle);
+		time = odp_time_counts();
+		diff  = odp_time_diff_counts(start_time, time);
 
 		if (wait < diff)
 			break;
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index ace280b..b6507c3 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -313,7 +313,7 @@  int main(int argc, char *argv[])
 	odph_linux_pthread_t thread_tbl[MAX_WORKERS];
 	int num_workers;
 	odp_queue_t queue;
-	uint64_t cycles, ns;
+	uint64_t counts, ns;
 	odp_queue_param_t param;
 	odp_pool_param_t params;
 	odp_timer_pool_param_t tparams;
@@ -438,21 +438,21 @@  int main(int argc, char *argv[])
 	}
 
 	printf("CPU freq %"PRIu64" Hz\n", odp_sys_cpu_hz());
-	printf("Cycles vs nanoseconds:\n");
+	printf("Counts vs nanoseconds:\n");
 	ns = 0;
-	cycles = odp_time_ns_to_counts(ns);
+	counts = odp_time_ns_to_counts(ns);
 
-	printf("  %12"PRIu64" ns      ->  %12"PRIu64" cycles\n", ns, cycles);
-	printf("  %12"PRIu64" cycles  ->  %12"PRIu64" ns\n", cycles,
-	       odp_time_counts_to_ns(cycles));
+	printf("  %12"PRIu64" ns      ->  %12"PRIu64" counts\n", ns, counts);
+	printf("  %12"PRIu64" counts  ->  %12"PRIu64" ns\n", counts,
+	       odp_time_counts_to_ns(counts));
 
 	for (ns = 1; ns <= 100*ODP_TIME_SEC; ns *= 10) {
-		cycles = odp_time_ns_to_counts(ns);
+		counts = odp_time_ns_to_counts(ns);
 
-		printf("  %12"PRIu64" ns      ->  %12"PRIu64" cycles\n", ns,
-		       cycles);
-		printf("  %12"PRIu64" cycles  ->  %12"PRIu64" ns\n", cycles,
-		       odp_time_counts_to_ns(cycles));
+		printf("  %12"PRIu64" ns      ->  %12"PRIu64" counts\n", ns,
+		       counts);
+		printf("  %12"PRIu64" counts  ->  %12"PRIu64" ns\n", counts,
+		       odp_time_counts_to_ns(counts));
 	}
 
 	printf("\n");
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index 0574536..8df078d 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -103,10 +103,10 @@  typedef union rx_stats_u {
 } pkt_rx_stats_t;
 
 struct tx_stats_s {
-	uint64_t tx_cnt;	/* Packets transmitted */
-	uint64_t alloc_failures;/* Packet allocation failures */
-	uint64_t enq_failures;	/* Enqueue failures */
-	uint64_t idle_cycles;	/* Idle cycle count in TX loop */
+	uint64_t tx_cnt;		/* Packets transmitted */
+	uint64_t alloc_failures;	/* Packet allocation failures */
+	uint64_t enq_failures;		/* Enqueue failures */
+	uint64_t idle_time;		/* Idle time count in TX loop */
 };
 
 typedef union tx_stats_u {
@@ -302,8 +302,8 @@  static void *run_thread_tx(void *arg)
 	int thr_id;
 	odp_queue_t outq;
 	pkt_tx_stats_t *stats;
-	uint64_t next_tx_cycles, end_cycles, cur_cycles;
-	uint64_t burst_gap_cycles;
+	uint64_t next_tx_time, end_time, cur_time;
+	uint64_t burst_gap_time;
 	uint32_t batch_len;
 	int unsent_pkts = 0;
 	odp_event_t  tx_event[BATCH_LEN_MAX];
@@ -325,33 +325,33 @@  static void *run_thread_tx(void *arg)
 	if (outq == ODP_QUEUE_INVALID)
 		LOG_ABORT("Failed to get output queue for thread %d\n", thr_id);
 
-	burst_gap_cycles = odp_time_ns_to_counts(
+	burst_gap_time = odp_time_ns_to_counts(
 				ODP_TIME_SEC / (targs->pps / targs->batch_len));
 
 	odp_barrier_wait(&globals->tx_barrier);
 
-	cur_cycles     = odp_time_counts();
-	next_tx_cycles = cur_cycles;
-	end_cycles     = cur_cycles +
+	cur_time     = odp_time_counts();
+	next_tx_time = cur_time;
+	end_time     = cur_time +
 			 odp_time_ns_to_counts(targs->duration * ODP_TIME_SEC);
 
-	while (cur_cycles < end_cycles) {
+	while (cur_time < end_time) {
 		unsigned alloc_cnt = 0, tx_cnt;
 
-		if (cur_cycles < next_tx_cycles) {
-			cur_cycles = odp_time_counts();
+		if (cur_time < next_tx_time) {
+			cur_time = odp_time_counts();
 			if (idle_start == 0)
-				idle_start = cur_cycles;
+				idle_start = cur_time;
 			continue;
 		}
 
 		if (idle_start) {
-			stats->s.idle_cycles += odp_time_diff_counts(
-							idle_start, cur_cycles);
+			stats->s.idle_time += odp_time_diff_counts(
+							idle_start, cur_time);
 			idle_start = 0;
 		}
 
-		next_tx_cycles += burst_gap_cycles;
+		next_tx_time += burst_gap_time;
 
 		alloc_cnt = alloc_packets(tx_event, batch_len - unsent_pkts);
 		if (alloc_cnt != batch_len)
@@ -362,14 +362,14 @@  static void *run_thread_tx(void *arg)
 		stats->s.enq_failures += unsent_pkts;
 		stats->s.tx_cnt += tx_cnt;
 
-		cur_cycles = odp_time_counts();
+		cur_time = odp_time_counts();
 	}
 
 	VPRINT(" %02d: TxPkts %-8"PRIu64" EnqFail %-6"PRIu64
 	       " AllocFail %-6"PRIu64" Idle %"PRIu64"ms\n",
 	       thr_id, stats->s.tx_cnt,
 	       stats->s.enq_failures, stats->s.alloc_failures,
-	       odp_time_counts_to_ns(stats->s.idle_cycles) / 1000 / 1000);
+	       odp_time_counts_to_ns(stats->s.idle_time) / 1000 / 1000);
 
 	return NULL;
 }
diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
index 3969111..98c5e43 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -183,7 +183,7 @@  static int test_alloc_single(int thr, odp_pool_t pool)
 {
 	int i;
 	odp_buffer_t temp_buf;
-	uint64_t t1, t2, cycles, ns;
+	uint64_t t1, t2, tdiff, ns;
 
 	t1 = odp_time_counts();
 
@@ -199,11 +199,11 @@  static int test_alloc_single(int thr, odp_pool_t pool)
 	}
 
 	t2     = odp_time_counts();
-	cycles = odp_time_diff_counts(t1, t2);
-	ns     = odp_time_counts_to_ns(cycles);
+	tdiff  = odp_time_diff_counts(t1, t2);
+	ns     = odp_time_counts_to_ns(tdiff);
 
-	printf("  [%i] alloc_sng alloc+free   %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, cycles/ALLOC_ROUNDS, ns/ALLOC_ROUNDS);
+	printf("  [%i] alloc_sng alloc+free   %"PRIu64" counts, %"PRIu64" ns\n",
+	       thr, tdiff / ALLOC_ROUNDS, ns / ALLOC_ROUNDS);
 
 	return 0;
 }
@@ -220,7 +220,7 @@  static int test_alloc_multi(int thr, odp_pool_t pool)
 {
 	int i, j;
 	odp_buffer_t temp_buf[MAX_ALLOCS];
-	uint64_t t1, t2, cycles, ns;
+	uint64_t t1, t2, tdiff, ns;
 
 	t1 = odp_time_counts();
 
@@ -239,11 +239,11 @@  static int test_alloc_multi(int thr, odp_pool_t pool)
 	}
 
 	t2     = odp_time_counts();
-	cycles = odp_time_diff_counts(t1, t2);
-	ns     = odp_time_counts_to_ns(cycles);
+	tdiff  = odp_time_diff_counts(t1, t2);
+	ns     = odp_time_counts_to_ns(tdiff);
 
-	printf("  [%i] alloc_multi alloc+free %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, cycles/(ALLOC_ROUNDS*MAX_ALLOCS),
+	printf("  [%i] alloc_multi alloc+free %"PRIu64" counts, %"PRIu64" ns\n",
+	       thr, tdiff / (ALLOC_ROUNDS * MAX_ALLOCS),
 	       ns/(ALLOC_ROUNDS*MAX_ALLOCS));
 
 	return 0;
@@ -265,7 +265,7 @@  static int test_poll_queue(int thr, odp_pool_t msg_pool)
 	odp_buffer_t buf;
 	test_message_t *t_msg;
 	odp_queue_t queue;
-	uint64_t t1, t2, cycles, ns;
+	uint64_t t1, t2, tdiff, ns;
 	int i;
 
 	/* Alloc test message */
@@ -311,11 +311,11 @@  static int test_poll_queue(int thr, odp_pool_t msg_pool)
 	}
 
 	t2     = odp_time_counts();
-	cycles = odp_time_diff_counts(t1, t2);
-	ns     = odp_time_counts_to_ns(cycles);
+	tdiff  = odp_time_diff_counts(t1, t2);
+	ns     = odp_time_counts_to_ns(tdiff);
 
-	printf("  [%i] poll_queue enq+deq     %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, cycles/QUEUE_ROUNDS, ns/QUEUE_ROUNDS);
+	printf("  [%i] poll_queue enq+deq     %"PRIu64" counts, %"PRIu64" ns\n",
+	       thr, tdiff / QUEUE_ROUNDS, ns / QUEUE_ROUNDS);
 
 	odp_buffer_free(buf);
 	return 0;
@@ -341,7 +341,7 @@  static int test_schedule_single(const char *str, int thr,
 {
 	odp_event_t ev;
 	odp_queue_t queue;
-	uint64_t t1, t2, cycles, ns;
+	uint64_t t1, t2, tdiff, ns;
 	uint32_t i;
 	uint32_t tot = 0;
 
@@ -383,17 +383,17 @@  static int test_schedule_single(const char *str, int thr,
 	odp_schedule_resume();
 
 	t2     = odp_time_counts();
-	cycles = odp_time_diff_counts(t1, t2);
-	ns     = odp_time_counts_to_ns(cycles);
+	tdiff  = odp_time_diff_counts(t1, t2);
+	ns     = odp_time_counts_to_ns(tdiff);
 
 	odp_barrier_wait(barrier);
 	clear_sched_queues();
 
-	cycles = cycles/tot;
+	tdiff = tdiff / tot;
 	ns     = ns/tot;
 
-	printf("  [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, str, cycles, ns);
+	printf("  [%i] %s enq+deq %"PRIu64" counts, %"PRIu64" ns\n",
+	       thr, str, tdiff, ns);
 
 	return 0;
 }
@@ -421,7 +421,7 @@  static int test_schedule_many(const char *str, int thr,
 	odp_queue_t queue;
 	uint64_t t1 = 0;
 	uint64_t t2 = 0;
-	uint64_t cycles, ns;
+	uint64_t tdiff, ns;
 	uint32_t i;
 	uint32_t tot = 0;
 
@@ -464,17 +464,17 @@  static int test_schedule_many(const char *str, int thr,
 	odp_schedule_resume();
 
 	t2     = odp_time_counts();
-	cycles = odp_time_diff_counts(t1, t2);
-	ns     = odp_time_counts_to_ns(cycles);
+	tdiff  = odp_time_diff_counts(t1, t2);
+	ns     = odp_time_counts_to_ns(tdiff);
 
 	odp_barrier_wait(barrier);
 	clear_sched_queues();
 
-	cycles = cycles/tot;
+	tdiff  = tdiff / tot;
 	ns     = ns/tot;
 
-	printf("  [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, str, cycles, ns);
+	printf("  [%i] %s enq+deq %"PRIu64" counts, %"PRIu64" ns\n",
+	       thr, str, tdiff, ns);
 
 	return 0;
 }
@@ -498,7 +498,7 @@  static int test_schedule_multi(const char *str, int thr,
 	odp_queue_t queue;
 	uint64_t t1 = 0;
 	uint64_t t2 = 0;
-	uint64_t cycles, ns;
+	uint64_t tdiff, ns;
 	int i, j;
 	int num;
 	uint32_t tot = 0;
@@ -585,22 +585,22 @@  static int test_schedule_multi(const char *str, int thr,
 
 
 	t2     = odp_time_counts();
-	cycles = odp_time_diff_counts(t1, t2);
-	ns     = odp_time_counts_to_ns(cycles);
+	tdiff  = odp_time_diff_counts(t1, t2);
+	ns     = odp_time_counts_to_ns(tdiff);
 
 	odp_barrier_wait(barrier);
 	clear_sched_queues();
 
 	if (tot) {
-		cycles = cycles/tot;
+		tdiff  = tdiff / tot;
 		ns     = ns/tot;
 	} else {
-		cycles = 0;
+		tdiff  = 0;
 		ns     = 0;
 	}
 
-	printf("  [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, str, cycles, ns);
+	printf("  [%i] %s enq+deq %"PRIu64" counts, %"PRIu64" ns\n",
+	       thr, str, tdiff, ns);
 
 	return 0;
 }
@@ -714,13 +714,13 @@  static void *run_thread(void *arg)
 }
 
 /**
- * @internal Test cycle counter accuracy
+ * @internal Test time counter accuracy
  */
 static void test_time(void)
 {
 	struct timespec tp1, tp2;
 	uint64_t t1, t2;
-	uint64_t ns1, ns2, cycles;
+	uint64_t ns1, ns2, tdiff;
 	double err;
 
 	if (clock_gettime(CLOCK_MONOTONIC, &tp2)) {
@@ -757,15 +757,15 @@  static void test_time(void)
 	else
 		ns1 -= tp1.tv_nsec - tp2.tv_nsec;
 
-	cycles = odp_time_diff_counts(t1, t2);
-	ns2    = odp_time_counts_to_ns(cycles);
+	tdiff  = odp_time_diff_counts(t1, t2);
+	ns2    = odp_time_counts_to_ns(tdiff);
 
 	err = ((double)(ns2) - (double)ns1) / (double)ns1;
 
 	printf("clock_gettime         %"PRIu64" ns\n",    ns1);
-	printf("odp_time_counts       %"PRIu64" cycles\n", cycles);
+	printf("odp_time_counts       %"PRIu64" counts\n", tdiff);
 	printf("odp_time_counts_to_ns %"PRIu64" ns\n",    ns2);
-	printf("odp get cycle error   %f%%\n", err*100.0);
+	printf("odp get count error   %f%%\n", err * 100.0);
 
 	printf("\n");
 }
@@ -898,7 +898,7 @@  int main(int argc, char *argv[])
 	printf("first CPU:          %i\n", odp_cpumask_first(&cpumask));
 	printf("cpu mask:           %s\n", cpumaskstr);
 
-	/* Test cycle count accuracy */
+	/* Test time count accuracy */
 	test_time();
 
 	shm = odp_shm_reserve("test_globals",
diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c
index 22d19a6..9db456c 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -212,10 +212,10 @@  static void *schedule_common_(void *arg)
 			CU_ASSERT(from != ODP_QUEUE_INVALID);
 			if (locked) {
 				int cnt;
-				uint64_t cycles = 0;
+				uint64_t time = 0;
 				/* Do some work here to keep the thread busy */
 				for (cnt = 0; cnt < 1000; cnt++)
-					cycles += odp_time_counts();
+					time += odp_time_counts();
 
 				odp_spinlock_unlock(&globals->atomic_lock);
 			}
diff --git a/test/validation/time/time.c b/test/validation/time/time.c
index 8ef7f2a..952d78a 100644
--- a/test/validation/time/time.c
+++ b/test/validation/time/time.c
@@ -11,48 +11,48 @@ 
 #define TOLERANCE 1
 #define BUSY_LOOP_CNT 100
 
-/* check that a cycles difference gives a reasonable result */
-static void time_test_odp_cycles_diff(void)
+/* check that a counts difference gives a reasonable result */
+static void time_test_odp_counts_diff(void)
 {
 	/* volatile to stop optimization of busy loop */
 	volatile int count = 0;
-	uint64_t diff, cycles1, cycles2;
+	uint64_t diff, counts1, counts2;
 
-	cycles1 = odp_time_counts();
+	counts1 = odp_time_counts();
 
 	while (count < BUSY_LOOP_CNT) {
 		count++;
 	};
 
-	cycles2 = odp_time_counts();
-	CU_ASSERT(cycles2 > cycles1);
+	counts2 = odp_time_counts();
+	CU_ASSERT(counts2 > counts1);
 
-	diff = odp_time_diff_counts(cycles1, cycles2);
+	diff = odp_time_diff_counts(counts1, counts2);
 	CU_ASSERT(diff > 0);
 }
 
-/* check that a negative cycles difference gives a reasonable result */
-static void time_test_odp_cycles_negative_diff(void)
+/* check that a negative counts difference gives a reasonable result */
+static void time_test_odp_counts_negative_diff(void)
 {
-	uint64_t diff, cycles1, cycles2;
+	uint64_t diff, counts1, counts2;
 
-	cycles1 = 10;
-	cycles2 = 5;
-	diff = odp_time_diff_counts(cycles1, cycles2);
+	counts1 = 10;
+	counts2 = 5;
+	diff = odp_time_diff_counts(counts1, counts2);
 	CU_ASSERT(diff > 0);
 }
 
 /* check that related conversions come back to the same value */
 static void time_test_odp_time_conversion(void)
 {
-	uint64_t ns1, ns2, cycles;
+	uint64_t ns1, ns2, counts;
 	uint64_t upper_limit, lower_limit;
 
 	ns1 = 100;
-	cycles = odp_time_ns_to_counts(ns1);
-	CU_ASSERT(cycles > 0);
+	counts = odp_time_ns_to_counts(ns1);
+	CU_ASSERT(counts > 0);
 
-	ns2 = odp_time_counts_to_ns(cycles);
+	ns2 = odp_time_counts_to_ns(counts);
 
 	/* need to check within arithmetic tolerance that the same
 	 * value in ns is returned after conversions */
@@ -62,8 +62,8 @@  static void time_test_odp_time_conversion(void)
 }
 
 CU_TestInfo time_suite_time[] = {
-	{"cycles diff", time_test_odp_cycles_diff},
-	{"negative diff", time_test_odp_cycles_negative_diff},
+	{"counts diff", time_test_odp_counts_diff},
+	{"negative diff", time_test_odp_counts_negative_diff},
 	{"conversion", time_test_odp_time_conversion},
 	 CU_TEST_INFO_NULL
 };