lkml.org 
[lkml]   [2014]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 16/50] mars: add new file drivers/block/mars/lib_timing.c
Date
Signed-off-by: Thomas Schoebel-Theuer <tst@schoebel-theuer.de>
---
drivers/block/mars/lib_timing.c | 51 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 drivers/block/mars/lib_timing.c

diff --git a/drivers/block/mars/lib_timing.c b/drivers/block/mars/lib_timing.c
new file mode 100644
index 0000000..9221c0b
--- /dev/null
+++ b/drivers/block/mars/lib_timing.c
@@ -0,0 +1,51 @@
+/* (c) 2012 Thomas Schoebel-Theuer / 1&1 Internet AG */
+
+#include <linux/brick/lib_timing.h>
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#ifdef CONFIG_MARS_DEBUG
+
+int report_timing(struct timing_stats *tim, char *str, int maxlen)
+{
+ int len = 0;
+ int time = 1;
+ int resol = 1;
+
+ static const char * const units[] = {
+ "us",
+ "ms",
+ "s",
+ "ERROR"
+ };
+ const char *unit = units[0];
+ int unit_index = 0;
+ int i;
+
+ for (i = 0; i < TIMING_MAX; i++) {
+ int this_len = scnprintf(str,
+
+ maxlen,
+ "<%d%s = %d (%lld) ",
+ resol,
+ unit,
+ tim->tim_count[i],
+ (long long)tim->tim_count[i] * time);
+ str += this_len;
+ len += this_len;
+ maxlen -= this_len;
+ if (maxlen <= 1)
+ break;
+ resol <<= 1;
+ time <<= 1;
+ if (resol >= 1000) {
+ resol = 1;
+ unit = units[++unit_index];
+ }
+ }
+ return len;
+}
+EXPORT_SYMBOL_GPL(report_timing);
+
+#endif
--
2.0.0


\
 
 \ /
  Last update: 2014-07-02 00:01    [W:0.481 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site