Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a772b2b authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt
Browse files

ring-buffer: replace constants with time macros in ring-buffer-benchmark



The use of numeric constants is discouraged. It is cleaner and more
descriptive to use macros for constant time conversions.

This patch also removes an extra new line.

[ Impact: more descriptive time conversions ]

Reported-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 79c5d3ce
Loading
Loading
Loading
Loading
+7 −5
Original line number Original line Diff line number Diff line
@@ -253,7 +253,7 @@ static void ring_buffer_producer(void)
	}
	}


	time = end_tv.tv_sec - start_tv.tv_sec;
	time = end_tv.tv_sec - start_tv.tv_sec;
	time *= 1000000;
	time *= USEC_PER_SEC;
	time += (long long)((long)end_tv.tv_usec - (long)start_tv.tv_usec);
	time += (long long)((long)end_tv.tv_usec - (long)start_tv.tv_usec);


	entries = ring_buffer_entries(buffer);
	entries = ring_buffer_entries(buffer);
@@ -273,7 +273,8 @@ static void ring_buffer_producer(void)
	pr_info("Missed:   %ld\n", missed);
	pr_info("Missed:   %ld\n", missed);
	pr_info("Hit:      %ld\n", hit);
	pr_info("Hit:      %ld\n", hit);


	do_div(time, 1000);
	/* Convert time from usecs to millisecs */
	do_div(time, USEC_PER_MSEC);
	if (time)
	if (time)
		hit /= (long)time;
		hit /= (long)time;
	else
	else
@@ -282,18 +283,19 @@ static void ring_buffer_producer(void)
	pr_info("Entries per millisec: %ld\n", hit);
	pr_info("Entries per millisec: %ld\n", hit);


	if (hit) {
	if (hit) {
		avg = 1000000 / hit;
		/* Calculate the average time in nanosecs */
		avg = NSEC_PER_MSEC / hit;
		pr_info("%ld ns per entry\n", avg);
		pr_info("%ld ns per entry\n", avg);
	}
	}



	if (missed) {
	if (missed) {
		if (time)
		if (time)
			missed /= (long)time;
			missed /= (long)time;


		pr_info("Total iterations per millisec: %ld\n", hit + missed);
		pr_info("Total iterations per millisec: %ld\n", hit + missed);


		avg = 1000000 / (hit + missed);
		/* Caculate the average time in nanosecs */
		avg = NSEC_PER_MSEC / (hit + missed);
		pr_info("%ld ns per entry\n", avg);
		pr_info("%ld ns per entry\n", avg);
	}
	}
}
}