From 80f25b79dadafa2246ce208c6a4e3a039701b692 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Fri, 3 Aug 2012 22:52:12 -0400 Subject: test session: Add SerialUSB benchmark to 'U' command. I'm currently measuring over 500 KB/sec with screen as my serial monitor. If I don't display the output at all, I get over 600 KB/sec. Nice! Signed-off-by: Marti Bolivar --- examples/test-session.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/test-session.cpp b/examples/test-session.cpp index 4316cda..284b4b0 100644 --- a/examples/test-session.cpp +++ b/examples/test-session.cpp @@ -4,6 +4,8 @@ // Useful for testing Maple features and troubleshooting. // Communicates over SerialUSB. +#include + #include // ASCII escape character @@ -17,8 +19,8 @@ uint8 gpio_state[BOARD_NR_GPIO_PINS]; -const char* dummy_data = ("qwertyuiopasdfghjklzxcvbnmmmmmm,./1234567890-=" - "qwertyuiopasdfghjklzxcvbnm,./1234567890"); +const char* dummy_data = ("123456789012345678901234567890\r\n" + "123456789012345678901234567890\r\n"); // Commands void cmd_print_help(void); @@ -155,11 +157,24 @@ void loop () { } break; - case 'U': + case 'U': { SerialUSB.println("Dumping data to USB. Press any key."); + int nprints = 0; + int start = millis(); while (!SerialUSB.available()) { SerialUSB.print(dummy_data); + nprints++; } + int elapsed = millis() - start; + SerialUSB.read(); // consume available character + size_t nbytes = nprints * strlen(dummy_data); + SerialUSB.println(); + SerialUSB.print("Sent "); + SerialUSB.print(nbytes); + SerialUSB.print(" bytes ("); + SerialUSB.print((nbytes / (double)elapsed) * (1000.0 / 1024.0)); + SerialUSB.println(" kB/sec)"); + } break; case 'g': @@ -270,7 +285,8 @@ void cmd_print_help(void) { "(delay)"); SerialUSB.println("\tp: test all PWM channels sequentially"); SerialUSB.println("\tW: dump data as fast as possible on all 3 USARTS"); - SerialUSB.println("\tU: dump data as fast as possible on USB"); + SerialUSB.println("\tU: dump data as fast as possible over USB" + " and measure data rate"); SerialUSB.println("\tg: toggle GPIOs sequentially"); SerialUSB.println("\tG: toggle GPIOs at the same time"); SerialUSB.println("\tj: toggle debug port GPIOs sequentially"); -- cgit v1.2.3