Author Topic: STM32 simple bechmark  (Read 2013 times)

0 Members and 1 Guest are viewing this topic.

Offline ebclrTopic starter

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
STM32 simple bechmark
« on: January 11, 2017, 09:51:46 am »
I use mbed sinewave example and evaluate the results on generating analog sinewave on 4 diferent nucleo boards  just for fun no optimization , only play mbed example

Results

F767        15.8 Khz
F429        5.98 Khz
F072RB    704 Hz
L152        638Hz


#include "mbed.h"

AnalogOut my_output(PA_4);

#define PI        (3.141592653589793238462)
#define AMPLITUDE (1.0)    // x * 3.3V
#define PHASE     (PI * 1) // 2*pi is one period
#define RANGE     (0x7FFF)
#define OFFSET    (0x7FFF)

// Configuration for sinewave output
#define BUFFER_SIZE (360)
uint16_t buffer[BUFFER_SIZE];

void calculate_sinewave(void);

int main() {
    printf("Sinewave example\n");
    calculate_sinewave();
    while(1) {     
        // sinewave output
        for (int i = 0; i < BUFFER_SIZE; i++) {
            my_output.write_u16(buffer);
//            wait_us(10);
        }
    }
}

// Create the sinewave buffer
void calculate_sinewave(void){
  for (int i = 0; i < BUFFER_SIZE; i++) {
     double rads = (PI * i)/180.0; // Convert degree in radian
     buffer = (uint16_t)(AMPLITUDE * (RANGE * (cos(rads + PHASE))) + OFFSET);
  }
}



 

Offline jaromir

  • Supporter
  • ****
  • Posts: 337
  • Country: sk
Re: STM32 simple bechmark
« Reply #1 on: January 11, 2017, 03:55:26 pm »
No optimization compilation usually produces awful code - it is useful just for debugging, where you need to step through code and not being disturbed by optimizer shuffling your code all over the shop or "hiding" variables. At least O1 optimization produces much better code density.
Along with "benchmark results" you should also provide CPU clock speed.

Benchmarks are somehow black magic, with lot of folks having very different opinions and discussing forever; some benchmarks are specific to particular action (floating point, random or sequential memory access) do work better on some architectures and perform poorly on another.
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: STM32 simple bechmark
« Reply #2 on: January 12, 2017, 05:30:58 am »
What CPU clock frequency was each board running at?
 
 


Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: STM32 simple bechmark
« Reply #4 on: January 12, 2017, 04:31:09 pm »
Easier to get the data from here I think https://developer.mbed.org/platforms/?pvend=10

I'm not sure exactly what the benchmark is testing (DAC output and simple loop?), but interesting to see the M3 at 32MHz is not much faster than M0 at 48Mhz. M4 is roughly 6x faster than M3, and M7 2x faster than M4.

It's obviously not just clock speed that is the factor, there are also differences in instruction sets, caching and bus architecture. It could be that all of the difference is down to caching, so probably a pretty useless benchmark.
Bob
"All you said is just a bunch of opinions."
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf