#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_log.h"
#define M2T(X) ((unsigned int)(X) / portTICK_PERIOD_MS) // ms to tick
#include "esp_random.h"
#include <sys/time.h>
static const char *TAG = "main";
#define dataLen 14400
void makeMatrixUint8(uint8_t *buf, int len)
{
for (int i = 0; i < len; i++)
{
esp_fill_random(&buf[i], sizeof(uint8_t));
}
}
void makeMatrixFloat(float *buf, int len)
{
for (int i = 0; i < len; i++)
{
esp_fill_random(&buf[i], sizeof(float));
}
}
static void testTask()
{
uint8_t *testData1 = (uint8_t *)malloc(sizeof(uint8_t) * dataLen);
float *testData2 = (float *)malloc(sizeof(float) * dataLen);
struct timeval tv_d0;
struct timeval tv_d1;
while (1)
{
makeMatrixUint8(testData1, dataLen);
makeMatrixFloat(testData2, dataLen);
gettimeofday(&tv_d0, NULL);
for (int t = 0; t < 10; t++)
{
for (int i = 0; i < dataLen; i++)
{
// testData2[i] = testData1[i] * 0.3;
testData2[i] = testData1[i] * 0.3f;
}
}
gettimeofday(&tv_d1, NULL);
int time = 1000000 * (tv_d1.tv_sec - tv_d0.tv_sec) + (tv_d1.tv_usec - tv_d0.tv_usec);
Serial.println(time);
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S3!");
testTask();
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1