-
Notifications
You must be signed in to change notification settings - Fork 9
/
Benchmark.h
52 lines (43 loc) · 1.36 KB
/
Benchmark.h
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
#ifndef BENCHMARK_H
#define BENCHMARK_H
#include <stdint.h>
#include "BuildConfig.h"
#include "Config.h"
#include "Protocol.h"
#include "SPIMaster.h"
#include "Utils.h"
namespace Benchmark {
inline void main(uint32_t renderMode) {
auto config = new Config(CONFIG_FILENAME);
auto spiMaster = new SPIMaster(
SPI_MODE,
(SPITiming){
.slowFrequency = renderMode == RENDER_MODE_BENCHMARK_2
? config->spiNormalTiming.fastFrequency
: config->spiNormalTiming.slowFrequency,
.fastFrequency = config->spiNormalTiming.fastFrequency,
.delayMicroseconds = config->spiNormalTiming.delayMicroseconds},
(SPITiming){
.slowFrequency = 0, .fastFrequency = 0, .delayMicroseconds = 0});
uint32_t goodPackets = 0;
uint32_t badPackets = 0;
uint32_t vblanks = 0;
while (true) {
uint32_t receivedPacket = spiMaster->exchange(0x98765432);
if (receivedPacket == 0x123456bb) {
goodPackets++;
vblanks++;
} else if (receivedPacket == 0x12345678)
goodPackets++;
else if (receivedPacket != 0xffffffff)
badPackets++;
if (vblanks >= 60) {
LOG(std::to_string(goodPackets) + " vs " + std::to_string(badPackets));
goodPackets = 0;
badPackets = 0;
vblanks = 0;
}
}
}
} // namespace Benchmark
#endif // BENCHMARK_H