-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6eb2dca
commit cbfed3d
Showing
1 changed file
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/** | ||
* @file ShellBenchmarks.ino | ||
* @version 1.0 | ||
* | ||
* @section License | ||
* Copyright (C) 2016, Mikael Patel | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* @section Description | ||
* This Arduino sketch measures the Shell library performance. | ||
*/ | ||
|
||
#include <Shell.h> | ||
|
||
// Shell 16 depth stack and 16 variables | ||
Shell<16,16> shell(Serial); | ||
|
||
#define BENCHMARK(script) \ | ||
do { \ | ||
uint32_t start0 = micros(); \ | ||
uint32_t start; \ | ||
while ((start = micros()) == start0); \ | ||
shell.execute(SCRIPT(script)); \ | ||
uint32_t stop = micros(); \ | ||
us = stop - start - baseline; \ | ||
Serial.print(F(script)); \ | ||
Serial.print(':'); \ | ||
Serial.print(us); \ | ||
Serial.print(':'); \ | ||
shell.print(); \ | ||
Serial.flush(); \ | ||
} while (0) | ||
|
||
void setup() | ||
{ | ||
Serial.begin(57600); | ||
while (!Serial); | ||
Serial.println(F("ShellBenchmarks: started")); | ||
Serial.flush(); | ||
|
||
uint32_t us, baseline = 0; | ||
BENCHMARK(""); | ||
baseline = us; | ||
|
||
BENCHMARK(" "); | ||
BENCHMARK(","); | ||
BENCHMARK("T"); | ||
BENCHMARK("F"); | ||
BENCHMARK("0"); | ||
BENCHMARK("1"); | ||
BENCHMARK("-1"); | ||
BENCHMARK("10"); | ||
BENCHMARK("-10"); | ||
BENCHMARK("100"); | ||
BENCHMARK("-100"); | ||
BENCHMARK("s"); | ||
BENCHMARK("ss"); | ||
BENCHMARK("r"); | ||
BENCHMARK("u"); | ||
BENCHMARK("o"); | ||
BENCHMARK("oo"); | ||
BENCHMARK("d"); | ||
BENCHMARK("j"); | ||
BENCHMARK("c"); | ||
|
||
BENCHMARK("10000,1000,100,10,1"); | ||
BENCHMARK("~"); | ||
BENCHMARK("n"); | ||
BENCHMARK("+"); | ||
BENCHMARK("-"); | ||
BENCHMARK("*"); | ||
BENCHMARK("/"); | ||
BENCHMARK("1+"); | ||
BENCHMARK("1-"); | ||
BENCHMARK("0<"); | ||
BENCHMARK("0>"); | ||
BENCHMARK("C"); | ||
|
||
BENCHMARK("0@"); | ||
BENCHMARK("0!"); | ||
|
||
BENCHMARK("{}x"); | ||
BENCHMARK("F{}i"); | ||
BENCHMARK("T{}i"); | ||
BENCHMARK("F{}{}e"); | ||
BENCHMARK("T{}{}e"); | ||
BENCHMARK("{F}w"); | ||
BENCHMARK("1,0{}l"); | ||
BENCHMARK("1,1{}l"); | ||
BENCHMARK("1,1{d}l"); | ||
BENCHMARK("1,10{d}l"); | ||
BENCHMARK("1,100{d}l"); | ||
|
||
BENCHMARK("1D"); | ||
BENCHMARK("10D"); | ||
BENCHMARK("M"); | ||
BENCHMARK("13O"); | ||
BENCHMARK("1,13W"); | ||
BENCHMARK("13H"); | ||
BENCHMARK("0,13W"); | ||
BENCHMARK("13L"); | ||
BENCHMARK("13R"); | ||
BENCHMARK("13X"); | ||
BENCHMARK("0A"); | ||
BENCHMARK("100,3P"); | ||
BENCHMARK("C"); | ||
|
||
BENCHMARK("0f"); | ||
|
||
shell.set(F("abs"), SCRIPT("u0<{n}i")); | ||
shell.set(F("min"), SCRIPT("oo>{s}id")); | ||
shell.set(F("max"), SCRIPT("oo<{s}id")); | ||
shell.set(F("fac"), SCRIPT("1,2r{*}l")); | ||
shell.set(F("5fac"), SCRIPT("5`fac:")); | ||
eeprom_busy_wait(); | ||
|
||
BENCHMARK("`abs"); | ||
BENCHMARK("`min"); | ||
BENCHMARK("`max"); | ||
BENCHMARK("`fac"); | ||
BENCHMARK("`5fac"); | ||
|
||
BENCHMARK("-10`abs@x"); | ||
BENCHMARK("-10`abs:"); | ||
BENCHMARK("-10,10`min:"); | ||
BENCHMARK("-10,10`max:"); | ||
BENCHMARK("5`fac:"); | ||
BENCHMARK("`5fac:"); | ||
} | ||
|
||
void loop() | ||
{ | ||
} |