summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-04-03 14:04:50 +0000
committerThomas Martitz <kugel@rockbox.org>2010-04-03 14:04:50 +0000
commitef0cc085adcb444e5d09faffde4c04d3b4894aea (patch)
treee971bd76f508b4164db39c65a3e1cd28d36b02b6
parent83ffe4339579ec96ebd1b9471eb25a098d39d9f8 (diff)
Memory benchmark plugin. Tests memory speeds and prints the kB/s.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25450 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/CATEGORIES1
-rw-r--r--apps/plugins/test_mem.c98
2 files changed, 99 insertions, 0 deletions
diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES
index f61ff9b69f..f797c4038d 100644
--- a/apps/plugins/CATEGORIES
+++ b/apps/plugins/CATEGORIES
@@ -100,6 +100,7 @@ stats,apps
stopwatch,apps
sudoku,games
test_boost,apps
+test_mem,apps
test_codec,viewers
test_disk,apps
test_fps,apps
diff --git a/apps/plugins/test_mem.c b/apps/plugins/test_mem.c
new file mode 100644
index 0000000000..bd9c86a0a5
--- /dev/null
+++ b/apps/plugins/test_mem.c
@@ -0,0 +1,98 @@
+/***************************************************************************
+* __________ __ ___.
+* Open \______ \ ____ ____ | | _\_ |__ _______ ___
+* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+* \/ \/ \/ \/ \/
+* $Id$
+*
+* Copyright (C) 2010 Thomas Martitz
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+* KIND, either express or implied.
+*
+****************************************************************************/
+
+#include "plugin.h"
+
+PLUGIN_HEADER
+
+#define BUF_SIZE ((PLUGIN_BUFFER_SIZE-(10<<10)) / (sizeof(int)))
+#define LOOP_REPEAT 8
+static volatile int buf[BUF_SIZE];
+#define KB_PER_SEC(delta) ((BUF_SIZE*sizeof(buf[0])*LOOP_REPEAT/delta) >> 10)
+
+enum plugin_status plugin_start(const void* parameter)
+{
+ (void)parameter;
+ bool done = false;
+ bool boost = false;
+ int count = 0;
+ int last_tick = 0;
+
+ rb->lcd_setfont(FONT_SYSFIXED);
+
+ while (!done)
+ {
+ unsigned i, j;
+ int line = 0;
+ int x;
+ int delta;
+ last_tick = *rb->current_tick;
+
+ for(i = 0; i < LOOP_REPEAT; i++)
+ {
+ for (j = 0; j < BUF_SIZE; j++)
+ buf[j] = j;
+ }
+ rb->screens[0]->clear_display();
+ rb->screens[0]->putsf(0, line++, "%s", boost?"boosted":"unboosted");
+ rb->screens[0]->putsf(0, line++, "bufsize: %u", BUF_SIZE*sizeof(buf[0]));
+ rb->screens[0]->putsf(0, line++, "loop#: %d", ++count);
+ delta = *rb->current_tick - last_tick;
+ rb->screens[0]->putsf(0, line++, "write ticks: %d (%d kB/s)", delta,
+ KB_PER_SEC(delta));
+ last_tick = *rb->current_tick;
+ for(i = 0; i < LOOP_REPEAT; i++)
+ {
+ for(j = 0; j < BUF_SIZE; j++)
+ x = buf[j];
+ }
+ delta = *rb->current_tick - last_tick;
+ rb->screens[0]->putsf(0, line++, "read ticks: %d (%d kB/s)", delta,
+ KB_PER_SEC(delta));
+ rb->screens[0]->update();
+
+ int button = rb->button_get(false);
+ switch (button)
+ {
+ case BUTTON_UP:
+ if (!boost)
+ {
+ rb->cpu_boost(true);
+ boost = true;
+ }
+ break;
+
+ case BUTTON_DOWN:
+ if (boost)
+ {
+ rb->cpu_boost(false);
+ boost = false;
+ }
+ break;
+
+ case BUTTON_LEFT:
+ done = true;
+ break;
+ }
+ }
+
+ return PLUGIN_OK;
+}