Index: apps/main_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/main_menu.c,v
retrieving revision 1.55
diff -u -b -r1.55 main_menu.c
--- apps/main_menu.c	31 Aug 2002 23:07:11 -0000	1.55
+++ apps/main_menu.c	4 Sep 2002 23:20:31 -0000
@@ -34,6 +34,8 @@
 #include "power.h"
 #include "powermgmt.h"
 #include "sound_menu.h"
+#include "ata.h"
+#include "mpeg.h"
 
 #ifdef HAVE_LCD_BITMAP
 #include "bmp.h"
@@ -196,6 +198,89 @@
     return MENU_OK;
 }
 
+Menu disk_bench(void)
+{
+    int i;
+    int count = 80; /* 10 MB */
+    long start;
+    long stop;
+    char buf[32];
+
+    mpeg_stop();
+    lcd_clear_display();
+    lcd_puts(0,0,"Disk speed");
+    lcd_update();
+
+    ata_read_sectors(0, 1, mp3buf);
+    start = current_tick;
+
+    for (i=0; i<count; i++ ) {
+        if (ata_read_sectors(i*256, 256, mp3buf)) {
+            snprintf(buf, sizeof buf, "read(%d) err", i);
+            lcd_puts(0,0,buf);
+            lcd_update();
+            sleep(HZ);
+            return MENU_OK;
+        }
+    }
+    stop = current_tick;
+    snprintf(buf, sizeof buf, "%d KB/s",
+             (count * 256 * 512 / 10) / (stop-start));
+    lcd_puts(0,1,buf);
+    lcd_update();
+    button_get(true);
+    return MENU_OK;
+}
+
+Menu cpu_bench1(void) __attribute__ ((section (".icode")));
+Menu cpu_bench1(void)
+{
+    int i;
+    long start = current_tick;
+    long stop;
+    char buf[32];
+
+    lcd_clear_display();
+    lcd_puts(0,0,"CPU speed IRAM");
+    lcd_update();
+
+    for (i=0; i < 1<<17; i++ ) {
+        int j;
+        for (j=0; j<80; j++ );
+    }
+
+    stop = current_tick;
+    snprintf(buf, sizeof buf, "%d ms", (stop-start)*10);
+    lcd_puts(0,1,buf);
+    lcd_update();
+    button_get(true);
+    return MENU_OK;
+}
+
+Menu cpu_bench2(void)
+{
+    int i;
+    long start = current_tick;
+    long stop;
+    char buf[32];
+
+    lcd_clear_display();
+    lcd_puts(0,0,"CPU speed DRAM");
+    lcd_update();
+
+    for (i=0; i < 1<<17; i++ ) {
+        int j;
+        for (j=0; j<80; j++ );
+    }
+
+    stop = current_tick;
+    snprintf(buf, sizeof buf, "%d ms", (stop-start)*10);
+    lcd_puts(0,1,buf);
+    lcd_update();
+    button_get(true);
+    return MENU_OK;
+}
+
 Menu main_menu(void)
 {
     int m;
@@ -220,6 +305,9 @@
 #else
         { "USB (sim)",          simulate_usb      },
 #endif
+        { "Disk benchmark",     disk_bench },
+        { "CPU benchmark IRAM",    cpu_bench1 },
+        { "CPU benchmark DRAM",    cpu_bench2 },
     };
 
     m=menu_init( items, sizeof items / sizeof(struct menu_items) );

