rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
rfi_perftest.cpp File Reference

Detailed Description

Method execution time micro test.

Date
Nov 30, 2012
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file rfi_perftest.cpp.

Functions

static void testSystemCalls (const int count)
 
static void testRusefiMethods (const int count)
 
static void testMath (const int count)
 
static void runTests (const int count)
 
static void timeInfo ()
 
static void runChibioTest ()
 
void initTimePerfActions ()
 

Variables

static Engine testEngine
 
Overflow64Counter halTime
 
static int rtcStartTime
 

Function Documentation

◆ initTimePerfActions()

void initTimePerfActions ( )

Definition at line 293 of file rfi_perftest.cpp.

293 {
294#if EFI_RTC
295 rtcStartTime = rtcGetTimeUnixSec(&RTCD1);
296#endif
297
298 addConsoleActionI("perftest", runTests);
299
300 addConsoleAction("timeinfo", timeInfo);
302}
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
static void timeInfo()
static int rtcStartTime
static void runTests(const int count)
static void runChibioTest()

Referenced by initEfiWithConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runChibioTest()

static void runChibioTest ( )
static

Definition at line 275 of file rfi_perftest.cpp.

275 {
276 print("EFI_SHAFT_POSITION_INPUT=%d\r\n", EFI_SHAFT_POSITION_INPUT);
277 print("EFI_EMULATE_POSITION_SENSORS=%d\r\n", EFI_EMULATE_POSITION_SENSORS);
278 print("EFI_ANALOG_SENSORS=%d\r\n", EFI_ANALOG_SENSORS);
279 print("EFI_INTERNAL_ADC=%d\r\n", EFI_INTERNAL_ADC);
280 print("EFI_MAP_AVERAGING=%d\r\n", EFI_MAP_AVERAGING);
281 print("EFI_LOGIC_ANALYZER=%d\r\n", EFI_LOGIC_ANALYZER);
282 print("EFI_ENGINE_SNIFFER=%d\r\n", EFI_ENGINE_SNIFFER);
283 print("EFI_SHAFT_POSITION_INPUT=%d\r\n", EFI_SHAFT_POSITION_INPUT);
284 print("EFI_ENGINE_CONTROL=%d\r\n", EFI_ENGINE_CONTROL);
285 print("CH_DBG_SYSTEM_STATE_CHECK=%d\r\n", CH_DBG_SYSTEM_STATE_CHECK);
286 print("CH_DBG_ENABLE_CHECKS=%d\r\n", CH_DBG_ENABLE_CHECKS);
287 print("CH_DBG_ENABLE_ASSERTS=%d\r\n", CH_DBG_ENABLE_ASSERTS);
288 print("CH_DBG_ENABLE_STACK_CHECK=%d\r\n", CH_DBG_ENABLE_STACK_CHECK);
289 print("CH_DBG_THREADS_PROFILING=%d\r\n", CH_DBG_THREADS_PROFILING);
290 TestThread(getConsoleChannel());
291}
msg_t TestThread(void *p)
Test execution thread function.
Definition test.c:296

Referenced by initTimePerfActions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runTests()

static void runTests ( const int  count)
static

Definition at line 250 of file rfi_perftest.cpp.

250 {
251 efiPrintf("Running tests: %d", count);
255}
static void testSystemCalls(const int count)
static void testRusefiMethods(const int count)
static void testMath(const int count)
uint16_t count
Definition tunerstudio.h:1

Referenced by initTimePerfActions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ testMath()

static void testMath ( const int  count)
static

Definition at line 96 of file rfi_perftest.cpp.

96 {
97 time_t start, time;
98
99 int64_t temp64 = 0;
100 start = getTimeNowMs();
101 for (int64_t i = 0; i < count; i++) {
102 temp64 += i;
103 }
104 time = getTimeNowMs() - start;
105 if (temp64 != 0) {
106 efiPrintf("Finished %d iterations of int64_t summation in %dms", count, time);
107 }
108
109 temp64 = 1;
110 start = getTimeNowMs();
111 for (int64_t i = 0; i < count; i++) {
112 temp64 *= i;
113 }
114 time = getTimeNowMs() - start;
115 if (temp64 == 0) {
116 efiPrintf("Finished %d iterations of int64_t multiplication in %dms", count, time);
117 }
118
119 start = getTimeNowMs();
120 for (int i = 0; i < count; i++)
121 ;
122 time = getTimeNowMs() - start;
123 efiPrintf("Finished %d iterations of empty loop in %dms", count, time);
124
125 uint32_t tempi = 1;
126 start = getTimeNowMs();
127 for (int i = 0; i < count; i++) {
128 tempi += tempi;
129 }
130 time = getTimeNowMs() - start;
131 if (tempi == 0) {
132 // 11ms is 1848000 ticks
133 // 18.48 ticks per iteration
134 // Finished 100000 iterations of uint32_t summation in 11ms
135 efiPrintf("Finished %d iterations of uint32_t summation in %dms", count, time);
136 }
137
138 start = getTimeNowMs();
139 tempi = 1;
140 for (int i = 0; i < count; i++) {
141 tempi += (tempi + 100) / 130;
142 }
143 time = getTimeNowMs() - start;
144 if (tempi != 0) {
145 // Finished 100000 iterations of uint32_t division in 16ms
146 efiPrintf("Finished %d iterations of uint32_t division in %dms", count, time);
147 }
148
149 start = getTimeNowMs();
150 temp64 = 1;
151 for (int i = 0; i < count; i++) {
152 temp64 += temp64;
153 }
154 time = getTimeNowMs() - start;
155 if (temp64 == 0) {
156 // Finished 100000 iterations of int64_t summation in 21ms
157 efiPrintf("Finished %d iterations of int64_t summation in %dms", count, time);
158 }
159
160 start = getTimeNowMs();
161 temp64 = 1;
162 for (int i = 0; i < count; i++) {
163 temp64 += (temp64 + 100) / 130;
164 }
165 time = getTimeNowMs() - start;
166 if (temp64 != 0) {
167 // Finished 100000 iterations of int64_t division in 181ms
168 efiPrintf("Finished %d iterations of int64_t division in %dms", count, time);
169 }
170
171 start = getTimeNowMs();
172 float tempf = 1;
173 for (int i = 0; i < count; i++) {
174 tempf += tempf;
175 }
176 time = getTimeNowMs() - start;
177 if (tempf != 0) {
178 efiPrintf("Finished %d iterations of float summation in %dms", count, time);
179 }
180
181 start = getTimeNowMs();
182 tempf = 1;
183 for (int i = 0; i < count; i++) {
184 tempf += tempf * 130.0f;
185 }
186 time = getTimeNowMs() - start;
187 if (tempf != 0) {
188 // ms = ticks
189 // ticks per iteration
190 // Finished 100000 iterations of float division in ms
191 efiPrintf("Finished %d iterations of float multiplication in %dms", count, time);
192 }
193
194 start = getTimeNowMs();
195 tempf = 1;
196 for (int i = 0; i < count; i++) {
197 tempf += (tempf + 100) / 130.0;
198 }
199 time = getTimeNowMs() - start;
200 if (tempf != 0) {
201 // 65 ms = 10920000 ticks
202 // 109.2 ticks per iteration
203 // Finished 100000 iterations of float division in 65ms
204 efiPrintf("Finished %d iterations of float division in %dms", count, time);
205 }
206
207 start = getTimeNowMs();
208 tempf = 1;
209 for (int i = 0; i < count; i++) {
210 tempf += logf(tempf);
211 }
212 time = getTimeNowMs() - start;
213 if (tempf != 0) {
214 // Finished 100000 iterations of float log in 191ms
215 efiPrintf("Finished %d iterations of float log in %dms", count, time);
216 }
217
218 start = getTimeNowMs();
219 double tempd = 1;
220 for (int i = 0; i < count; i++)
221 tempd += tempd / 2;
222 time = getTimeNowMs() - start;
223 if (tempd != 0) {
224 // Finished 100000 iterations of double summation in 80ms
225 efiPrintf("Finished %d iterations of double summation in %dms", count, time);
226 }
227
228 start = getTimeNowMs();
229 tempd = 1;
230 for (int i = 0; i < count; i++)
231 tempd += (tempd + 100) / 130.0;
232 time = getTimeNowMs() - start;
233 if (tempd != 0) {
234 // Finished 100000 iterations of double division in 497ms
235 efiPrintf("Finished %d iterations of double division in %dms", count, time);
236 }
237
238 start = getTimeNowMs();
239 tempd = 1;
240 for (int i = 0; i < count; i++) {
241 tempd += log(tempd);
242 }
243 time = getTimeNowMs() - start;
244 if (tempd != 0) {
245 // Finished 100000 iterations of double log in 242ms
246 efiPrintf("Finished %d iterations of double log in %dms", count, time);
247 }
248}
efitimems_t getTimeNowMs()
Returns the 32 bit number of milliseconds since the board initialization.
Definition efitime.cpp:34

Referenced by runTests().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ testRusefiMethods()

static void testRusefiMethods ( const int  count)
static

Definition at line 69 of file rfi_perftest.cpp.

69 {
70 time_t start, time;
71 int tempi = 1;
72
73 start = getTimeNowMs();
74
75 time = getTimeNowMs() - start;
76 if (tempi != 0)
77 efiPrintf("Finished %d iterations of getBaseFuel in %dms", count, time);
78
79// start = getTimeNowMs();
80// for (int i = 0; i < count; i++)
81// tempi += getInjectionDuration(1200, NULL); // todo
82// time = getTimeNowMs() - start;
83// if (tempi != 0)
84// efiPrintf("Finished %d iterations of getFuelMs in %dms", count, time);
85
86 start = getTimeNowMs();
87 for (int i = 0; i < count; i++) {
89 tempi += testEngine.engineState.clt;
90 }
91 time = getTimeNowMs() - start;
92 if (tempi != 0)
93 efiPrintf("Finished %d iterations of updateSlowSensors in %dms", count, time);
94}
void updateSlowSensors()
Definition engine.cpp:208
EngineState engineState
Definition engine.h:344
static Engine testEngine

Referenced by runTests().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ testSystemCalls()

static void testSystemCalls ( const int  count)
static

Definition at line 22 of file rfi_perftest.cpp.

22 {
23 time_t start, time;
24 long result = 0;
25
26 start = getTimeNowMs();
27 for (int i = 0; i < count / 2; i++) {
28// setPinValue(&testOutput, 0);
29// setPinValue(&testOutput, 1);
30 }
31
32 time = getTimeNowMs() - start;
33 // Finished 100000 iterations of 'setPinValue()' in 120ms
34// prin("Finished %d iterations of 'setPinValue()' in %dms\r\n", count, time);
35
36 start = getTimeNowMs();
37 for (int i = 0; i < count; i++)
38 result += chTimeNow();
39 time = getTimeNowMs() - start;
40 if (result != 0) {
41 // Finished 100000 iterations of 'chTimeNow()' in 33ms
42 efiPrintf("Finished %d iterations of 'chTimeNow()' in %dms", count, time);
43 }
44
45 start = getTimeNowMs();
46 for (int i = 0; i < count; i++) {
47 chSysLock()
48 ;
49 result += chTimeNow();
50 chSysUnlock()
51 ;
52 }
53 time = getTimeNowMs() - start;
54 if (result != 0) {
55 // Finished 100000 iterations of 'chTimeNow()' with chSysLock in 144ms
56 efiPrintf("Finished %d iterations of 'chTimeNow()' with chSysLock in %dms", count, time);
57 }
58
59 start = getTimeNowMs();
60 for (int i = 0; i < count; i++)
61 result += getTimeNowMs();
62 time = getTimeNowMs() - start;
63 if (result != 0)
64 efiPrintf("Finished %d iterations of 'getTimeNowMs' in %dms", count, time);
65}

Referenced by runTests().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeInfo()

static void timeInfo ( )
static

Definition at line 265 of file rfi_perftest.cpp.

265 {
266 efiPrintf("chTimeNow as seconds = %d", getTimeNowS());
267 efiPrintf("hal seconds = %d", halTime.get() / (long)STM32_SYSCLK);
268
269#if EFI_RTC
270 int unix = rtcGetTimeUnixSec(&RTCD1) - rtcStartTime;
271 efiPrintf("unix seconds = %d", unix);
272#endif
273}
efitimesec_t getTimeNowS()
Current system time in seconds (32 bits)
Definition efitime.cpp:42
Overflow64Counter halTime

Referenced by initTimePerfActions().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ halTime

Overflow64Counter halTime
extern

Referenced by timeInfo().

◆ rtcStartTime

int rtcStartTime
static

Definition at line 260 of file rfi_perftest.cpp.

Referenced by initTimePerfActions(), and timeInfo().

◆ testEngine

Engine testEngine
static

Definition at line 67 of file rfi_perftest.cpp.

Referenced by testRusefiMethods().

Go to the source code of this file.