Repository navigation
Expand file tree
/
Copy pathShellBenchmarks.ino
More file actions
187 lines (163 loc) · 3.94 KB
/
Copy pathShellBenchmarks.ino
File metadata and controls
187 lines (163 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/**
* @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 to benchmark scripts in data memory
#ifdef USE_SRAM_SCRIPTS
#undef SCRIPT
#define SCRIPT(x) x
#endif
#define BENCHMARK(script) \
do { \
uint32_t start; \
uint32_t start0 = micros(); \
while ((start = micros()) == start0); \
shell.execute(F(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{1-q}w");
BENCHMARK("10{1-q}w");
BENCHMARK("100{1-q}w");
BENCHMARK("1000{1-q}w");
BENCHMARK("10000{1-q}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("1,1000{d}l");
BENCHMARK("1,10000{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("1,1000{d1,13W}l");
BENCHMARK("1,1000{d13H}l");
BENCHMARK("1,1000{d0,13W}l");
BENCHMARK("1,1000{d13L}l");
BENCHMARK("1,1000{d13Rd}l");
BENCHMARK("1,1000{d13R~13W}l");
BENCHMARK("1,1000{d13X}l");
BENCHMARK("1,1000{dA0d}l");
BENCHMARK("0f");
shell.set(F("abs"), F("u0<{n}i"));
shell.set(F("min"), F("oo>{s}id"));
shell.set(F("max"), F("oo<{s}id"));
shell.set(F("fac"), F("1,2r{*}l"));
shell.set(F("fac5"), F("5`fac"));
shell.set(F("x"), 0);
shell.set(F("y"), 0);
eeprom_busy_wait();
BENCHMARK(":abs");
BENCHMARK(":min");
BENCHMARK(":max");
BENCHMARK(":fac");
BENCHMARK(":fac5");
BENCHMARK(":x");
BENCHMARK(":y");
BENCHMARK("C");
BENCHMARK("-10:abs@x");
BENCHMARK("-10`abs");
BENCHMARK("-10,10`min");
BENCHMARK("-10,10`max");
BENCHMARK("5`fac");
BENCHMARK("`fac5");
BENCHMARK("C");
BENCHMARK(":x@");
BENCHMARK(":y!");
BENCHMARK(":x,u@1+s!");
BENCHMARK(":x@:y!");
BENCHMARK("C");
BENCHMARK("0f");
shell.set(F("fib"), F("u1>{u1-`fib,s2-`fib+}i"));
eeprom_busy_wait();
BENCHMARK(":fib");
BENCHMARK("10`fib");
}
void loop()
{
}