diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/CATEGORIES | 1 | ||||
-rw-r--r-- | apps/plugins/test_mem.c | 98 |
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 | |||
100 | stopwatch,apps | 100 | stopwatch,apps |
101 | sudoku,games | 101 | sudoku,games |
102 | test_boost,apps | 102 | test_boost,apps |
103 | test_mem,apps | ||
103 | test_codec,viewers | 104 | test_codec,viewers |
104 | test_disk,apps | 105 | test_disk,apps |
105 | test_fps,apps | 106 | 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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Thomas Martitz | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "plugin.h" | ||
23 | |||
24 | PLUGIN_HEADER | ||
25 | |||
26 | #define BUF_SIZE ((PLUGIN_BUFFER_SIZE-(10<<10)) / (sizeof(int))) | ||
27 | #define LOOP_REPEAT 8 | ||
28 | static volatile int buf[BUF_SIZE]; | ||
29 | #define KB_PER_SEC(delta) ((BUF_SIZE*sizeof(buf[0])*LOOP_REPEAT/delta) >> 10) | ||
30 | |||
31 | enum plugin_status plugin_start(const void* parameter) | ||
32 | { | ||
33 | (void)parameter; | ||
34 | bool done = false; | ||
35 | bool boost = false; | ||
36 | int count = 0; | ||
37 | int last_tick = 0; | ||
38 | |||
39 | rb->lcd_setfont(FONT_SYSFIXED); | ||
40 | |||
41 | while (!done) | ||
42 | { | ||
43 | unsigned i, j; | ||
44 | int line = 0; | ||
45 | int x; | ||
46 | int delta; | ||
47 | last_tick = *rb->current_tick; | ||
48 | |||
49 | for(i = 0; i < LOOP_REPEAT; i++) | ||
50 | { | ||
51 | for (j = 0; j < BUF_SIZE; j++) | ||
52 | buf[j] = j; | ||
53 | } | ||
54 | rb->screens[0]->clear_display(); | ||
55 | rb->screens[0]->putsf(0, line++, "%s", boost?"boosted":"unboosted"); | ||
56 | rb->screens[0]->putsf(0, line++, "bufsize: %u", BUF_SIZE*sizeof(buf[0])); | ||
57 | rb->screens[0]->putsf(0, line++, "loop#: %d", ++count); | ||
58 | delta = *rb->current_tick - last_tick; | ||
59 | rb->screens[0]->putsf(0, line++, "write ticks: %d (%d kB/s)", delta, | ||
60 | KB_PER_SEC(delta)); | ||
61 | last_tick = *rb->current_tick; | ||
62 | for(i = 0; i < LOOP_REPEAT; i++) | ||
63 | { | ||
64 | for(j = 0; j < BUF_SIZE; j++) | ||
65 | x = buf[j]; | ||
66 | } | ||
67 | delta = *rb->current_tick - last_tick; | ||
68 | rb->screens[0]->putsf(0, line++, "read ticks: %d (%d kB/s)", delta, | ||
69 | KB_PER_SEC(delta)); | ||
70 | rb->screens[0]->update(); | ||
71 | |||
72 | int button = rb->button_get(false); | ||
73 | switch (button) | ||
74 | { | ||
75 | case BUTTON_UP: | ||
76 | if (!boost) | ||
77 | { | ||
78 | rb->cpu_boost(true); | ||
79 | boost = true; | ||
80 | } | ||
81 | break; | ||
82 | |||
83 | case BUTTON_DOWN: | ||
84 | if (boost) | ||
85 | { | ||
86 | rb->cpu_boost(false); | ||
87 | boost = false; | ||
88 | } | ||
89 | break; | ||
90 | |||
91 | case BUTTON_LEFT: | ||
92 | done = true; | ||
93 | break; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | return PLUGIN_OK; | ||
98 | } | ||