diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2012-08-03 22:52:12 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2012-08-03 22:53:31 -0400 |
commit | 80f25b79dadafa2246ce208c6a4e3a039701b692 (patch) | |
tree | e8c1bb8d28bfb0907deaf3c018f316a954055ce0 /examples | |
parent | 822f42bc46b93f4cd6f0825e74a28a76a43e1f90 (diff) | |
download | librambutan-80f25b79dadafa2246ce208c6a4e3a039701b692.tar.gz librambutan-80f25b79dadafa2246ce208c6a4e3a039701b692.zip |
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 <mbolivar@leaflabs.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/test-session.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
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 <string.h> + #include <wirish/wirish.h> // 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"); |