I posted this yesterday again,...but messed up the post, by giving too much info. Here is everything bare as good as it gets:
Arduino: ~1.000.000 while(1)++
espidf: ~10.000.000 while(1)++
I even reinstalled Vs Code and Platformio, only C++ pack added and tested different board.json. Only difference was memory so far.
Everything is default in Platformio.
I tested many different build flags, but nothing changes it really dramatic, maybe 10-20%.
I read many threads, about that topic, but nothing helped in my case.
Whats going on?
patformio.ini
[env:esp32-s3-devkitc1-n16r8]
platform = espressif32
board = esp32-s3-devkitc1-n16r8
framework = arduino
monitor_speed = 115200
arduino:
#include <esp_timer.h>
#include "driver/uart.h"
unsigned long long lastResetTime = 0;
unsigned long performanceCounter = 0;
void setup() {
uart_set_baudrate(1, 115200);
lastResetTime = esp_timer_get_time();
}
void loop() {
while (1)
{
performanceCounter++;
unsigned long long currentTime = esp_timer_get_time();
if (currentTime - lastResetTime >= 1000000) {
printf("Performance score: %lu\n", performanceCounter);
performanceCounter = 0;
lastResetTime = currentTime;
} /* code */
}
}
I give you the code of espidf also,....maybe it cheated somehow..lol
But I confirmed it's counting +1 and one second is one second.
Not sure what to try else.... ![]()
espidf:
lastResetTime = xTaskGetTickCount() * portTICK_PERIOD_MS;
unsigned long performanceCounter = 0;
while (true) {
// Increment the performance counter
performanceCounter++;
// Check if one second has passed
if (xTaskGetTickCount() * portTICK_PERIOD_MS - lastResetTime >= 1000) {
// Log the performance score and reset the counter
ESP_LOGI(TAG, "Performance score: %lu|", performanceCounter);
performanceCounter = 0; // Reset the counter
lastResetTime = xTaskGetTickCount() * portTICK_PERIOD_MS; // Update the reset time
}
}