[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <f0625e0068a3efc9f7b289032ed4cc4e952178ae.1310993826.git.andriy.shevchenko@linux.intel.com>
Date: Mon, 18 Jul 2011 15:57:54 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: linux-kernel@...r.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Alexey Dobriyan <adobriyan@...il.com>
Subject: [PATCHv2 2/2] lib: kstrtox: add performance test case
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Alexey Dobriyan <adobriyan@...il.com>
---
lib/test-kstrtox.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/lib/test-kstrtox.c b/lib/test-kstrtox.c
index d55769d..2da5950 100644
--- a/lib/test-kstrtox.c
+++ b/lib/test-kstrtox.c
@@ -65,6 +65,12 @@ struct test_fail {
} \
}
+static int loop_amount;
+
+module_param(loop_amount, int, 0);
+MODULE_PARM_DESC(loop_amount,
+ "Amount of loops for performance test (0 - no test)");
+
static void __init test_kstrtoull_ok(void)
{
DECLARE_TEST_OK(unsigned long long, struct test_ull);
@@ -707,6 +713,27 @@ static void __init test_kstrtos8_fail(void)
TEST_FAIL(kstrtos8, s8, "%hhd", test_s8_fail);
}
+static void __init test_kstrtox_perf(void)
+{
+ struct timespec ts, ts1, ts2;
+ int count = loop_amount;
+
+ if (!loop_amount)
+ return;
+
+ getnstimeofday(&ts1);
+ while (count--) {
+ test_kstrtoull_ok();
+ test_kstrtoull_fail();
+ }
+ getnstimeofday(&ts2);
+ ts = timespec_sub(ts2, ts1);
+
+ printk(KERN_INFO "kstrox: %d conversions of strings took %lu.%09lu "
+ "seconds\n", loop_amount,
+ (unsigned long)ts.tv_sec, (unsigned long)ts.tv_nsec);
+}
+
static int __init test_kstrtox_init(void)
{
test_kstrtoull_ok();
@@ -733,6 +760,9 @@ static int __init test_kstrtox_init(void)
test_kstrtou8_fail();
test_kstrtos8_ok();
test_kstrtos8_fail();
+
+ test_kstrtox_perf();
+
return -EINVAL;
}
module_init(test_kstrtox_init);
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists