Index: kernel/generic/include/func.h
===================================================================
--- kernel/generic/include/func.h	(revision 771cd22b02d9fec4d7d601d12b2979a07abb50db)
+++ kernel/generic/include/func.h	(revision 95155b0cd020d126e09ca42230ae0a4dce3f296c)
@@ -49,4 +49,5 @@
 extern void strncpy(char *dest, const char *src, size_t len);
 extern unative_t atoi(const char *text);
+extern void order(const uint64_t val, uint64_t *rv, char *suffix);
 
 #endif
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 771cd22b02d9fec4d7d601d12b2979a07abb50db)
+++ kernel/generic/src/console/cmd.c	(revision 95155b0cd020d126e09ca42230ae0a4dce3f296c)
@@ -117,4 +117,23 @@
 	.argc = 1,
 	.argv = test_argv
+};
+
+static int cmd_bench(cmd_arg_t *argv);
+static cmd_arg_t bench_argv[] = {
+	{
+		.type = ARG_TYPE_STRING,
+		.buffer = test_buf,
+		.len = sizeof(test_buf)
+	},
+	{
+		.type = ARG_TYPE_INT,
+	}
+};
+static cmd_info_t bench_info = {
+	.name = "bench",
+	.description = "Run kernel test as benchmark.",
+	.func = cmd_bench,
+	.argc = 2,
+	.argv = bench_argv
 };
 #endif
@@ -412,4 +431,5 @@
 	&tests_info,
 	&test_info,
+	&bench_info,
 #endif
 	NULL
@@ -872,5 +892,5 @@
 	
 	/* Execute the test */
-	char * ret = test->entry();
+	char * ret = test->entry(false);
 	
 	/* Update and read thread accounting */
@@ -881,5 +901,9 @@
 	interrupts_restore(ipl);
 	
-	printf("Time: %llu cycles\n", dt);
+	uint64_t cycles;
+	char suffix;
+	order(dt, &cycles, &suffix);
+		
+	printf("Time: %llu%c cycles\n", cycles, suffix);
 	
 	if (ret == NULL) {
@@ -890,4 +914,70 @@
 	printf("%s\n", ret);
 	return false;
+}
+
+static bool run_bench(const test_t *test, const uint32_t cnt)
+{
+	uint32_t i;
+	bool ret = true;
+	uint64_t cycles;
+	char suffix;
+	
+	if (cnt < 1)
+		return true;
+	
+	uint64_t *data = malloc(sizeof(uint64_t) * cnt, 0);
+	if (data == NULL) {
+		printf("Error allocating memory for statistics\n");
+		return false;
+	}
+	
+	for (i = 0; i < cnt; i++) {
+		printf("%s (%d/%d) ... ", test->name, i + 1, cnt);
+		
+		/* Update and read thread accounting
+		   for benchmarking */
+		ipl_t ipl = interrupts_disable();
+		spinlock_lock(&TASK->lock);
+		uint64_t t0 = task_get_accounting(TASK);
+		spinlock_unlock(&TASK->lock);
+		interrupts_restore(ipl);
+		
+		/* Execute the test */
+		char * ret = test->entry(true);
+		
+		/* Update and read thread accounting */
+		ipl = interrupts_disable();
+		spinlock_lock(&TASK->lock);
+		uint64_t dt = task_get_accounting(TASK) - t0;
+		spinlock_unlock(&TASK->lock);
+		interrupts_restore(ipl);
+		
+		if (ret != NULL) {
+			printf("%s\n", ret);
+			ret = false;
+			break;
+		}
+		
+		data[i] = dt;
+		order(dt, &cycles, &suffix);
+		printf("OK (%llu%c cycles)\n", cycles, suffix);
+	}
+	
+	if (ret) {
+		printf("\n");
+		
+		uint64_t sum = 0;
+		
+		for (i = 0; i < cnt; i++) {
+			sum += data[i];
+		}
+		
+		order(sum / (uint64_t) cnt, &cycles, &suffix);
+		printf("Average\t\t%llu%c\n", cycles, suffix);
+	}
+	
+	free(data);
+	
+	return ret;
 }
 
@@ -927,4 +1017,32 @@
 	return 1;
 }
+
+/** Command for returning kernel tests as benchmarks
+ *
+ * @param argv Argument vector.
+ *
+ * return Always 1.
+ */
+int cmd_bench(cmd_arg_t *argv)
+{
+	test_t *test;
+	uint32_t cnt = argv[1].intval;
+	
+	bool fnd = false;
+	
+	for (test = tests; test->name != NULL; test++) {
+		if (strcmp(test->name, argv->buffer) == 0) {
+			fnd = true;
+			run_bench(test, cnt);
+			break;
+		}
+	}
+		
+	if (!fnd)
+		printf("Unknown test\n");
+
+	return 1;
+}
+
 #endif
 
Index: kernel/generic/src/lib/func.c
===================================================================
--- kernel/generic/src/lib/func.c	(revision 771cd22b02d9fec4d7d601d12b2979a07abb50db)
+++ kernel/generic/src/lib/func.c	(revision 95155b0cd020d126e09ca42230ae0a4dce3f296c)
@@ -222,4 +222,22 @@
 }
 
+
+void order(const uint64_t val, uint64_t *rv, char *suffix)
+{
+	if (val > 1000000000000000000LL) {
+		*rv = val / 1000000000000000000LL;
+		*suffix = 'E';
+	} else if (val > 1000000000000LL) {
+		*rv = val / 1000000000000LL;
+		*suffix = 'T';
+	} else if (val > 1000000LL) {
+		*rv = val / 1000000LL;
+		*suffix = 'M';
+	} else {
+		*rv = val;
+		*suffix = ' ';
+	}
+}
+
 /** @}
  */
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 771cd22b02d9fec4d7d601d12b2979a07abb50db)
+++ kernel/generic/src/proc/task.c	(revision 95155b0cd020d126e09ca42230ae0a4dce3f296c)
@@ -53,4 +53,5 @@
 #include <lib/elf.h>
 #include <errno.h>
+#include <func.h>
 #include <syscall/copy.h>
 #include <console/klog.h>
@@ -392,18 +393,7 @@
 			spinlock_lock(&t->lock);
 			
-			uint64_t cycles = task_get_accounting(t);
+			uint64_t cycles;
 			char suffix;
-			
-			if (cycles > 1000000000000000000LL) {
-				cycles = cycles / 1000000000000000000LL;
-				suffix = 'E';
-			} else if (cycles > 1000000000000LL) {
-				cycles = cycles / 1000000000000LL;
-				suffix = 'T';
-			} else if (cycles > 1000000LL) {
-				cycles = cycles / 1000000LL;
-				suffix = 'M';
-			} else 
-				suffix = ' ';
+			order(task_get_accounting(t), &cycles, &suffix);
 			
 			printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd %6zd", t->taskid, t->name, t->context, t, t->as, cycles, suffix, t->refcount, atomic_get(&t->active_calls));
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision 771cd22b02d9fec4d7d601d12b2979a07abb50db)
+++ kernel/generic/src/proc/thread.c	(revision 95155b0cd020d126e09ca42230ae0a4dce3f296c)
@@ -570,18 +570,5 @@
 			uint64_t cycles;
 			char suffix;
-			
-			if (t->cycles > 1000000000000000000LL) {
-				cycles = t->cycles / 1000000000000000000LL;
-				suffix = 'E';
-			} else if (t->cycles > 1000000000000LL) {
-				cycles = t->cycles / 1000000000000LL;
-				suffix = 'T';
-			} else if (t->cycles > 1000000LL) {
-				cycles = t->cycles / 1000000LL;
-				suffix = 'M';
-			} else {
-				cycles = t->cycles;
-				suffix = ' ';
-			}
+			order(t->cycles, &cycles, &suffix);
 			
 			printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx %#10zx %9llu%c ", t->tid, t->name, t, thread_states[t->state], t->task, t->task->context, t->thread_code, t->kstack, cycles, suffix);
