Tests on M7 and M4 core.
M7 is the master core at 480MHz.
M4 is the secondary one, at 240MHz.
#ifdef CORE_CM7
#define _write(...) { Serial.write(__VA_ARGS__); }
#define _print(...) { Serial.print(__VA_ARGS__); }
#define _println(...) { Serial.println(__VA_ARGS__); }
#else
#define _print(...) { RPC.print(__VA_ARGS__); }
#define _println(...) { RPC.print(__VA_ARGS__); RPC.print("\n"); }
#endif
int ledRGB[]={D86,D87,D88};
DigitalOutput led[3]; // Uses the class in post #1
void test()
{
int i,t1,t2;
// LED control pins as output
pinMode(ledRGB[0], OUTPUT);
pinMode(ledRGB[1], OUTPUT);
pinMode(ledRGB[2], OUTPUT);
// LED control pins seen through class DigitalOutput
// as inverted pins
led[0].init(GPIOI,12,true);
led[1].init(GPIOJ,13,true);
led[2].init(GPIOE, 3,true);
// test 1 : usage of standard digitalWrite()
// ------
t1 = millis();
for(i=0;i<1000000;i++)
{
digitalWrite(ledRGB[0], LOW);
digitalWrite(ledRGB[0], HIGH);
}
t2 = millis();
_println("delta1 = " + String(t2-t1));
// test 2 : usage of setHigh()/setLow()
// ------
t1 = millis();
for(i=0;i<1000000;i++)
{
led[0].setHigh();
led[0].setLow();
}
t2 = millis();
_println("delta2 = " + String(t2-t1));
// Test for fun (same price !) : 100000 square roots
double f = 100000000000000.0;
t1 = millis();
for(i=0;i<100000;i++)
{
f = sqrt(f+0.1);
}
t2 = millis();
_println("delta sqrt = " + String(t2-t1));
}
Results (in ms) :
M7 :
delta1 = 259
delta2 = 51
delta sqrt = 19
M4 :
delta1 = 645
delta2 = 23
delta sqrt = 505
The results are quite unexpected :
-
M7 is twice faster then M4 in clock speed, but twice slower in test 2 !?!
-
100000 square roots take 19ms on M7 but 505ms on M4 (25x slower).
Conclusions :
- M4 with class DigitalOutputs leaves the M7 far behind !
- M7 is for calculations, seeming to be the only one with a FPU.