* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: Arduino Benchmark  (Read 3318 times)

0 Members and 1 Guest are viewing this topic.

Offline semiprocoder

  • Full User
  • Join Date: May 2015
  • Location:
  • Posts: 272
  • Post Rating Ratio: +2/-0
    • awesommee333
    • 114/11470
    • View Profile
  • Gender: Male
Arduino Benchmark
« on: September 29, 2015, 10:08:03 pm »
About half a year ago I made a benchmark for the arduino because I wanted to see how much faster my then new arduino due was than my arduino uno and micro. I don't know why, but I decided that I will(perhaps, not sure yet) start programming arduino again(since that benchmark I pretty much didn't even touch arduino anymore). The main reason that I stopped arduino was cause I suck at hardware stuff so I couldn't really do anything special, but I did make pong(and I tried to make don't touch the spikes(an amazing remake of flappy bird), but resistive touchscreens are not really meant for capacitive uses), if anyone is interested.

Anyways, back to the arduinos and my benchmark. My benchmark has a large macro, which is divided by the time the arduino took to complete the benchmark. That time is the score the arduino gets at the end. The due turned out to indeed be a lot faster and got a score almost six times as big as the uno and micro, and, unsurprisingly, and my micro got a slightly lower(but practically insignificant) score compared to my uno. Here is my code:

Code: [Select]
#define ITER 200000L
#define SCORE_DIVIDER 99999999L
#define UNO_SCORE 563L// I might eventually use this to guess which arduino you are benchmarking
#define MICRO_SCORE 559L
#define DUE_SCORE 3301L
#define MALLOC_SIZE 256
void printFloat(float value, unsigned long precision){
   Serial.print(int(value));
   Serial.print(".");
   unsigned long frac;
   if (value >= 0)
      frac = (value - long(value)) * precision;
   else
      frac = (long(value) - value) * precision;
   Serial.println(frac, DEC);
}
void setup() {
   Serial.begin(57600);
   long Millis=millis();
   long increment = 0;
   float f = 0.0f;
   Serial.println("checking float performance using random");
   for (; increment < ITER; increment++) {
      f = random(0.0f, (float)increment);
   }
   Serial.print("rand performance time taken: ");
   Serial.println(millis() - Millis);
   Millis = millis();
   Serial.println("now calculating PI using Newtonian method...");
   long Millis2 = millis();
   float pi = 0.0f;
   float multiplier = 1.0f;
   for (float incrementf = 0.0f, increment=0; increment < ITER; incrementf+=1.0f, increment++){
      pi += 4.0f / (incrementf*2.0f + 1.0f)*multiplier;
      multiplier *= -1.0f;
   }
   Serial.print("PI estimating time: ");
   Serial.print(millis() - Millis2);
   Millis2 = millis();
   Serial.print(" PI estimate: ");
   Serial.println(pi, 8);
   Serial.println("About to test polar to rectangular coordinate conversion: ");
   long Millis3 = millis();
   float X = 0.0f;
   float Y = 0.0f;
   f = 0.0f;
   for (long i = 0L; i < ITER/3; i++, f+=PI/1000.0f){
      X = cos(f)*((float)i)/1000.0f;
      Y = sin(f)*((float)i) / 1000.0f;
   }
   Serial.print("Polar to rect coords converting time: ");
   Serial.println(millis() - Millis3);
   Serial.print("X: ");
   Serial.println(X, 8);
   Serial.print("Y: ");
   Serial.println(Y, 8);
   Millis3 = millis();
   Serial.println("now testing mem write speed(mallocing and freeing pointers):");
   long Millis4;
   for (long i = 0; i < ITER/4; i++){
      char *j = (char*)malloc(MALLOC_SIZE);
      char *f = j;
      for (int i = 0; i < MALLOC_SIZE; i++){
         *f = 'n';//just some random value to initialize the whole array of chars with
         f++;
      }
      free(j);
   }
   Serial.print("Ram test finished in: ");
   Serial.print(millis() - Millis4);
   Serial.println(" milliseconds");
   Serial.print("malloc size is: ");
   Serial.println(MALLOC_SIZE);
   Millis4 = millis();
   long score = Millis + Millis2 + Millis3+Millis4;
   score = SCORE_DIVIDER / score;
   Serial.println("Your arduino's score is: ");
   Serial.print(score);
}

void loop() {
}

-----------------------------------------

By the way, should I make myself a thread just for my old code(or just make this thread for all my code), cause I have a bunch of old codes I want to showcase(like pong for android, 2d minecraft in processing, 2048 in processing, a 2d platformer I made that I need to restore(well finish and fix not restore I don't have any way of doing that) because I made it on my school computer, so my comp doesn't have the working version and the version on my comp is outdated). Not all of it is polished or that good or anything, but some of my code(in my opinion) is not too bad.

Edit (Streetwalrus): merged double post.
« Last Edit: October 01, 2015, 12:12:30 pm by Streetwalrus »


  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

Online Streetwalrus

  • Professional slacker
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2784
  • Post Rating Ratio: +19/-0
  • ƎW∀⅁ ƎH⊥
    • View Profile
  • Gender: Male
Re: Arduino Benchmark
« Reply #1 on: October 01, 2015, 12:14:11 pm »
You should keep it all in one thread unless you have a big project to showcase, in which case it's better to create a new thread for it. :)
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen

Offline semiprocoder

  • Full User
  • Join Date: May 2015
  • Location:
  • Posts: 272
  • Post Rating Ratio: +2/-0
    • awesommee333
    • 114/11470
    • View Profile
  • Gender: Male
Re: Arduino Benchmark
« Reply #2 on: October 01, 2015, 07:30:14 pm »
Yeah thats what I was planning to do.
  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

Online DarkestEx

  • Super User
  • News Editor
  • Join Date: Jan 2015
  • Location:
  • Posts: 1297
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • View Profile
    • My homepage
  • Gender: Male
Re: Arduino Benchmark
« Reply #3 on: October 01, 2015, 07:38:41 pm »
Nice idea of performance testing.

It might be a little off-topic, but I wanted to say this about arduino for aa long time now.
I don't like some concepts of it and their results.
Like arduino is great for real EE beginners or for quick prototyping, but in no way is the arduino code style efficient; its just slow with all that abstraction and it doesn't make awitching to real ARM-C or AVR-C easy at all. Even the few extra MHz of the due or the different architecture will change that.
Another thing that I don't like is that everything has to be arduino compatible.
And the final thing is, that the concept if using shields is a bad thing in my opinion. You just end up with a huge, expensive stack of PCBs and nothing permanent.
Apart from that, it has a great and capable community.

These are also reasons (especially the bad coding style and the C++) that we don't make the microcat arduino compatible.
« Last Edit: October 01, 2015, 07:41:57 pm by DarkestEx »
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s
<- Check out Claw if you like writing code once and having it run on most embedded devices alike :)

Avatar drewn for me by Tabbes.

Offline p4nix

  • Full User
  • Join Date: Jun 2015
  • Location: Germany
  • Posts: 401
  • Post Rating Ratio: +6/-1
  • Don't catch the ball.
    • p4nix
    • View Profile
  • Gender: Male
Re: Arduino Benchmark
« Reply #4 on: October 01, 2015, 07:44:03 pm »
Yeah, there are guys using the whole circuit board although they could come up with something more stable and smaller even on breadboard if they just use what they need (the micro + power supply + their stuff)...
  • Calculators owned: fx9860GII (SH4)

Online DarkestEx

  • Super User
  • News Editor
  • Join Date: Jan 2015
  • Location:
  • Posts: 1297
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • View Profile
    • My homepage
  • Gender: Male
Re: Arduino Benchmark
« Reply #5 on: October 01, 2015, 07:52:42 pm »
Yeah, there are guys using the whole circuit board although they could come up with something more stable and smaller even on breadboard if they just use what they need (the micro + power supply + their stuff)...
That is what I was doing in the past (soldering it standalone). But I am switching to real register based c now.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s
<- Check out Claw if you like writing code once and having it run on most embedded devices alike :)

Avatar drewn for me by Tabbes.

Offline semiprocoder

  • Full User
  • Join Date: May 2015
  • Location:
  • Posts: 272
  • Post Rating Ratio: +2/-0
    • awesommee333
    • 114/11470
    • View Profile
  • Gender: Male
Re: Arduino Benchmark
« Reply #6 on: October 01, 2015, 08:01:34 pm »
I don't know. Arduino seems pretty fast too me. Of course it's no asm(which I don't know yet but would be happy if someone sent me a nice tutorial, although I'm not really trying to do so right now), but still. Compared to something like ti basic, it whizzes along at ridiculous speed. The main reason I personally don't really like arduino(although I still like it cause of some of the uses for it) is cause I suck at hardware stuff(I can still do some simple wire connecting on a breadboard obviously, but not too much more), don't really feel like soldering, and I really don't like that tiny 2kb of ram. Cmon, it should have more. Also I tried using the due for some of this stuff but still, it is not compatible with like any arduino shields, which is annoying.

Also I don't know, shields are kind of nice. As I said before not good at hardware so I really like shields because they make it easier to do everything.
« Last Edit: October 01, 2015, 08:07:43 pm by semiprocoder »
  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

Online DarkestEx

  • Super User
  • News Editor
  • Join Date: Jan 2015
  • Location:
  • Posts: 1297
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • View Profile
    • My homepage
  • Gender: Male
Re: Arduino Benchmark
« Reply #7 on: October 02, 2015, 06:53:10 am »
I don't know. Arduino seems pretty fast too me. Of course it's no asm(which I don't know yet but would be happy if someone sent me a nice tutorial, although I'm not really trying to do so right now), but still. Compared to something like ti basic, it whizzes along at ridiculous speed. The main reason I personally don't really like arduino(although I still like it cause of some of the uses for it) is cause I suck at hardware stuff(I can still do some simple wire connecting on a breadboard obviously, but not too much more), don't really feel like soldering, and I really don't like that tiny 2kb of ram. Cmon, it should have more. Also I tried using the due for some of this stuff but still, it is not compatible with like any arduino shields, which is annoying.

Also I don't know, shields are kind of nice. As I said before not good at hardware so I really like shields because they make it easier to do everything.
Yes I see the speed difference. If you use arduino, try using the proper C functions and registers, like PORTA and so instead of digitalWrite and digitalRead.
These are big problems of the arduino platform as digitalRead and write are so abstracted that they are very slow. ASM is not required in the most cases except inline assembly for speed critical parts.
C++ is not the particulary best choice for a such limited platform (C would be more appropriate).

Back to the microcat. I used a new processor that is currently not usable in open source projects as it has no API yet.
We work on this so others can use our processor in their projects too.
Our microprocessor is only 2-3 EUR more expensive than the arduino unos processor, but has USB 2.0, multiple serial ports, infrared, parallel io controller, high speed multimedia card interface (SD support), 128KB ram with the possibility of executing machine code from there, 512KB flash, Serial and USB boot loader right from factory in internal ROM, ~50 io pins, up to 120MHz clock, ARMv7 processor architecture, built-in real time clock, SPI up to 40MHz, I2C, I2S, 16 bit PWM, 10 bit DAC.

Making a small PCB breakout of it and using the API that we are building currently, it should be an awesome platform.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s
<- Check out Claw if you like writing code once and having it run on most embedded devices alike :)

Avatar drewn for me by Tabbes.

Offline semiprocoder

  • Full User
  • Join Date: May 2015
  • Location:
  • Posts: 272
  • Post Rating Ratio: +2/-0
    • awesommee333
    • 114/11470
    • View Profile
  • Gender: Male
Re: Arduino Benchmark
« Reply #8 on: October 02, 2015, 07:19:07 pm »
Well, I agree that digitalwrite and read are really slow, cause bit manipulation is pretty fast compared to bit maniuplation and bunch of like error checking or whatever it was(I looked at the source a while ago but don't remember what it is so I'm guessing here). But the problem with just using PORTB, PORTC, PORTD is that it doesn't work on all the arduinos and changes from like uno to due. Of course, when I actually need speed I would use the bit manipulation, but otherwise, eh.

Also a question about the microcat: Are any ports going to be open for use, with the screen and all being built in, and what voltage and amperage are they running at? Also the API is going to be in c, right?

And I don't extensively use c++. I learned c and then self taught some c++, but I don't really use it(don't even remember how to use cout), unless I want to make a library with classes or something. Also I use int *i=new int
  • (for some reason brackets are being a bullet point) when I want to make variable length arrays and feel lazy, cause I don't always feel like using malloc and then keep track of my pointers and stuff.
« Last Edit: October 02, 2015, 07:28:45 pm by semiprocoder »
  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

Online DarkestEx

  • Super User
  • News Editor
  • Join Date: Jan 2015
  • Location:
  • Posts: 1297
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • View Profile
    • My homepage
  • Gender: Male
Re: Arduino Benchmark
« Reply #9 on: October 02, 2015, 08:41:44 pm »
Also a question about the microcat: Are any ports going to be open for use, with the screen and all being built in, and what voltage and amperage are they running at? Also the API is going to be in c, right?

And I don't extensively use c++. I learned c and then self taught some c++, but I don't really use it(don't even remember how to use cout), unless I want to make a library with classes or something. Also I use int *i=new int(x)(for some reason brackets are being a bullet point) when I want to make variable length arrays and feel lazy, cause I don't always feel like using malloc and then keep track of my pointers and stuff.
[/quote]
Of course will there. There will be 3 SPI, 1 (infrared) serial, 1 I2C port and > 15 free GPIO pins that will be usable for anything that the game or OS developer wants.
One SPI port is occupied with the OLED, one serial port is occupied with the ESP8266, one serial port is for testing, and the usb port is hooked up to the USB jack (USB host and slave).
The operating voltage of the IO is 3.3v, the internal voltage is 1.2v. The processor will draw up to 100mA maximum (if i did not missread).
And the API will be C, right.

The brackets are interpreted as so called "Bulletin Board Code" or BBCode which is a markup language for forums.
Try putting it into
Code: [Select]
[code]myval[x][\code] boxes (with this slash: /).
« Last Edit: October 02, 2015, 08:43:56 pm by DarkestEx »
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s
<- Check out Claw if you like writing code once and having it run on most embedded devices alike :)

Avatar drewn for me by Tabbes.

Offline semiprocoder

  • Full User
  • Join Date: May 2015
  • Location:
  • Posts: 272
  • Post Rating Ratio: +2/-0
    • awesommee333
    • 114/11470
    • View Profile
  • Gender: Male
Re: Arduino Benchmark
« Reply #10 on: October 03, 2015, 07:49:43 pm »
Thats nice. So you will be able to use it like an arduino and as a retro game player-. Also maybe some old fashioned serial communication for games just for the heck of it. Also will you just connect a keyboard to the microcat or will it have its own dedicated set of buttons. Will it have a joystick?

Also, straying from hardware a little bit, what do you plan the os to be like. Will it be like the ti 84 with a simple file interface and a main screen, or will it be like a skinned down version of linux?
  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

Online DarkestEx

  • Super User
  • News Editor
  • Join Date: Jan 2015
  • Location:
  • Posts: 1297
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • View Profile
    • My homepage
  • Gender: Male
Re: Arduino Benchmark
« Reply #11 on: October 05, 2015, 12:21:32 am »
Thats nice. So you will be able to use it like an arduino and as a retro game player-. Also maybe some old fashioned serial communication for games just for the heck of it. Also will you just connect a keyboard to the microcat or will it have its own dedicated set of buttons. Will it have a joystick?

Also, straying from hardware a little bit, what do you plan the os to be like. Will it be like the ti 84 with a simple file interface and a main screen, or will it be like a skinned down version of linux?
Well it has USB and serial communication and WiFi (last one allows for multiplayer across the world :))
It had a joystick, but we replaced it for a few reasons with a  dpad. It has 4 direction keys on the left and 4 action buttons on the right. It also has a game independent home and power button.

About the os I thought to make it something in between something like scaled down Linux and a 84+ style OS structure.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s
<- Check out Claw if you like writing code once and having it run on most embedded devices alike :)

Avatar drewn for me by Tabbes.

Online DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 17439
  • Post Rating Ratio: +83/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Re: Arduino Benchmark
« Reply #12 on: October 05, 2015, 04:18:27 am »
The OS should probably be simple at first but provide some functionalities that phone users would commonly use.  Just as long as launching games is as easy as it can get, unlike some consoles.
  • Calculators owned: TI-73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX, HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Online DarkestEx

  • Super User
  • News Editor
  • Join Date: Jan 2015
  • Location:
  • Posts: 1297
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • View Profile
    • My homepage
  • Gender: Male
Re: Arduino Benchmark
« Reply #13 on: October 05, 2015, 02:12:09 pm »
The OS should probably be simple at first but provide some functionalities that phone users would commonly use.  Just as long as launching games is as easy as it can get, unlike some consoles.
Well we plan having a nice colorful loader and settings app which will probably be in flash, but they could end up being put onto the SD card.
And yes the os won't get too big.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s
<- Check out Claw if you like writing code once and having it run on most embedded devices alike :)

Avatar drewn for me by Tabbes.

Offline semiprocoder

  • Full User
  • Join Date: May 2015
  • Location:
  • Posts: 272
  • Post Rating Ratio: +2/-0
    • awesommee333
    • 114/11470
    • View Profile
  • Gender: Male
Re: Arduino Benchmark
« Reply #14 on: October 05, 2015, 11:36:37 pm »
That's awesome. I don't really like having to go through an entire complex os just to get to games or to access the ports. Also I don't really know linux commands because I am too lazy to learn them, but a simple os makes everything easier. Also do you plan to make the api like arduino. I know it is in c but I mean like will the functions be similar? Or will you have an api completely different and evolving from arduino.
  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games