Simple Benchmarks

basically miscellaneous, if it doesn't fit another sub-forum enter it here, we might even promote it to its own sub-forum
Post Reply
basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Simple Benchmarks

Post by basicchip »

I should have published something like this a long time ago. Of course you can find CoreMark tests for all these CPUs. But I thought I would give a simple test of BASIC with a floating point divide in the loop.

Code: Select all

dim x as single
x=1000000
while x>1
i=i+1
x=x/1.0001
loop
The variable i was there just to count iterations - 138140

Rooted around the office for various parts -- some never became products, or were specials versions for OEM customers

And the envelope please--
  • LPC824 4193 msec
  • LPC1549 3719 msec
  • LPC11U68 2855 msec
  • LPC11U37 2706 msec
  • LPC1114 2700 msec
  • Teensy3.2 795 msec
  • LPC1751 519 msec
  • LPC1756 511 msec
  • LPC54102 101 msec
  • LPC4078 73 msec
  • LPC54005 43 msec
  • LPC4330 39 msec
  • GPD PC 31 msec Atom x7 z8750 1.6 GHz
  • Dell PC 9 msec i5 3330S 2.76 GHz
Now the PC's are interpreting the BASIC, not compiled like the ARM



basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Simple Benchmarks

Post by basicchip »

Mike just walked me through generating code for SAMD21 -- known as Arduino Zero

and --
  • SAMD21 1887 msec
Check the blog at https://www.coridium.us/coridium/blog/some-benchmarks for more complete numbers

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Simple Benchmarks

Post by basicchip »

Just for reference here is an equivalent program in C for another CPU. If you don't declare the variables volatile, gcc can optimize the whole loop out of existance.

Code: Select all

#include "mstimer.h"

volatile int i;
volatile float x;

int main()                                    // Main function
{
  printf("starting\n");
  mstime_set(0);
  mstime_start();
  i = 1000000;
  while (i) {      
    i=i-1;  // same speed i--;
  }
  mstime_stop();
  printf("integer time %d\n",mstime_get());

 
  mstime_set(0);
  mstime_start();
  x = 1000000;
  while (x>1) {
    i=i+1;
    x=x/1.0001;
  }    
  mstime_stop();
  printf("float time %d\n",mstime_get()); 
}

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Simple Benchmarks

Post by basicchip »

And for an older CPU, the float was 73994 msec, and integer time was 9399 msec. Yep chips have gotten faster over the years.

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Simple Benchmarks

Post by basicchip »

I found a PC BASIC that is compiled rather than interpreted. It is QB64 and compiles to 64 bit op codes, it comes it about 10x faster than the PC-ARMbasic emulator.

Added that to the benchmarks blog table. https://www.coridium.us/coridium/blog/some-benchmarks

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Simple Benchmarks

Post by basicchip »

Got a couple micromites, as I was curious about performance on those interpreters.

48 MHz PIC32MX170F256B which according to Coremark are a bit faster than the same MHz ARM Cortex M0.

float test -- 23.606 seconds
integer test -- 81.992 seconds

While it a cute solution if you have a VT100 lying around, most people connect them to PCs, so not sure the Apple2 on a chip makes as much sense as a use case. Though I have talked to people who think it's a good fit for their application and they went that way vs. our compiler.

I applaud another BASIC designer, and tip my hat to his complete package. Yes his documentation is better than mine.

Also got a microbit so will test that too.

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Simple Benchmarks

Post by basicchip »

Microbit numbers now posted at the list in the blog.

https://www.coridium.us/coridium/blog/some-benchmarks

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Simple Benchmarks

Post by basicchip »

As part of the Kickstarter for uChip, someone asked about performance of BASIC. So I did a quick comparison of my benchmarks in C vs BASIC.

Turns out the integer benchmark runs about the same for C and BASIC. Not real surprising as not much to optimize there.

The float benchmark threw me for a bit of a loss, as the C was running about 3 times slower. So from MakeItC I did a ASM listing to see what was going on. Turns out gcc was converting the numbers to double precision, then calculating and then converting back. I'm sure there is some setting I could do or some cast to keep it single precision. But it was surprising.

My benchmarks are very simple tests and not really meant as any kind of exhaustive comparison. Just a simple ballpark answer.

In general gcc will do better optimizations than BASIC, so it will be faster in many cases.

https://www.kickstarter.com/projects/70 ... ero-boards

Post Reply