T4 simple speed test

Status
Not open for further replies.

Gadget999

Well-known member
I had 5 mins today to play with the new T4

I am counting the number of cycles in approx one second

on average we are seeing approx 7.8 million loops !


is there a neater way to do this or could this be used as a benchmark between models ?


Code:
int Counter = 0;
unsigned long TickCount = 0;

void setup() {

Serial.begin(9600);
TickCount = millis();

}

void loop() {

Counter ++;

if (millis() - TickCount > 1000) {
  Serial.println(Counter);
  TickCount = millis();
  Counter = 0;
}

}
 
@Gadget999

Typically we have been using Coremark to measure performance between boards. @manitou ran this test for the various board with different CPU Clock settings in post #235. Paul also post the Coremark program you can run yourself if you wish. The link is in post #3927 of the T4 Beta test thread. Its fun to run by the way.
 
That does show 7+M loops/sec. That is just testing a simple loop Call/Return process - it is telling and impressive and good for a reference number knowing when loop() processing slows as code is added. As KurtE notes there are other benchmarks - Paul also posted one doing an RSA Key calc.

FUNNY: Just playing with this - I posted a BUG on the T4_Beta thread - t_sermon pukes errors to the console when a number is selected {to get the values below in comments} during Upload and sermon restarts.

Adding void yield takes the number to 14+M. Shows numbers at 20M when not leaving loop().

Code is below it shows another oddity for Counter as int versus uint32_t - but his may change as the diff is small:
int is faster with PJRC yield
uint32_t is faster with void yield.

Code with alternate loop() using elapsedMillis - gives about same #'s - note the time compare should be ">=":
Code:
//int Counter = 0; // w/yield=7860523
//uint32_t Counter = 0; // w/yield=7772251
//int Counter = 0; // void yield=14298589
//uint32_t Counter = 0; // void yield=14647405
//int Counter = 0; // while(1)=200179593
uint32_t Counter = 0; // while(1)=200179597

unsigned long TickCount = 0;
//void yield() {}

void setup() {
  Serial.begin(9600);
  TickCount = millis();
}

void loop() {
  while (1) // optional - don't leave loop
  {
    Counter ++;
    if (millis() - TickCount > 1000) {
      Serial.println(Counter);
      TickCount = millis();
      Counter = 0;
    }
  }
}

elapsedMillis Watch;
void loopXX() {
  while (1) // optional - don't leave loop
  {
    Counter ++;
    if (Watch > 1000) {
      Serial.println(Counter);
      Watch = 0;
      Counter = 0;
    }
  }
}
 
loop() is just called repeatedly from a main() function entry. So with that minimal amount of code in loop() - that return and cycle to enter again doubles the time and halves the count.

Also in that cycle for Arduino support of serialEvent() calls for USB and UARTS having in coming data between calls to loop() it calls yield() which scans those .available() in some fashion adding the other overhead dropped with the local yield().

So staying in the local while(1) loop that overhead is removed - it just seems super significant because otherwise nothing at all is happening but checking the time.
 
Status
Not open for further replies.
Back
Top