30SEC BENCHMARK
A standardized 30-second prime number calculation benchmark for Arduino, ESP32, and RISC-V boards. Measures raw arithmetic throughput and CPU efficiency across microcontroller architectures.
A standardized 30-second prime number calculation benchmark for Arduino, ESP32, and RISC-V boards. Measures raw arithmetic throughput and CPU efficiency across microcontroller architectures.
Leverages millisecond-precise hardware timers to execute a non-blocking prime search loop, terminating cleanly at exactly 30,000ms.
Implements early even-number pruning and step-by-two odd trial division up to sqrt(N), maximizing raw integer computation throughput.
Runs identically across 8-bit AVR microcontrollers (ATmega328P, ATmega2560) and 32-bit modern processors (ESP32 Xtensa, ESP32-C3 RISC-V).
Streams immediate diagnostic data and final prime count over USB UART (115200 baud) without CPU-throttling string formatting inside the hot loop.
Zero dynamic heap allocation (no malloc/free or String objects) preventing heap fragmentation and ensuring pure bare-metal determinism.
Provides an empirical baseline for comparing clock frequencies, pipeline depths, and instruction cycles across embedded development platforms.
| Microcontroller Platform | CPU Architecture & Clock | Category | Arithmetic Characteristics |
|---|---|---|---|
| ESP32 DevKit (Xtensa LX6) | 32-bit Dual-Core @ 240MHz | Hardware integer divider & branch prediction | |
| ESP32-C3 Super Mini (RISC-V) | 32-bit Single-Core @ 160MHz | Compact RV32IMC core with efficient caching | |
| Arduino Uno / Nano (ATmega328P) | 8-bit AVR @ 16MHz | Pure software 32-bit long integer emulation | |
| Arduino Mega 2560 (ATmega2560) | 8-bit AVR @ 16MHz | Expanded flash memory baseline |
The benchmark initiates with timestamp calibration via millis(), cycling candidate primes through an optimized trial division routine until the 30-second boundary is crossed:
unsigned long startTime = millis();
unsigned long count = 0;
unsigned long candidate = 2;
while (millis() - startTime < 30000) {
if (isPrime(candidate)) {
count++;
}
candidate++;
}
Serial.print("Primes calculated in 30 seconds: ");
Serial.println(count);