You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

Arduino Benchmark

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

0
b/Hardware publicado por u/semiprocoder 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:


#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
Inicia sesión o crea una cuenta para dejar un comentario
u/novenary 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. :)
u/semiprocoder October 01, 2015, 07:30:14 PM
Yeah thats what I was planning to do.
u/DarkestEx 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
u/p4nix 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)...
u/DarkestEx October 01, 2015, 07:52:42 PM
Quote from: p4nix 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)...
That is what I was doing in the past (soldering it standalone). But I am switching to real register based c now.
u/semiprocoder 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
u/DarkestEx October 02, 2015, 06:53:10 AM
Quote from: semiprocoder 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.
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.
u/semiprocoder 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
u/DarkestEx 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]myval[x][\code] boxes (with this slash: /).
Last Edit: October 02, 2015, 08:43:56 PM by DarkestEx
u/semiprocoder 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?
u/DarkestEx October 05, 2015, 12:21:32 AM
Quote from: semiprocoder 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?
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.
u/Dream of Omnimaga 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.
u/DarkestEx October 05, 2015, 02:12:09 PM
Quote from: DJ Omnimaga 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.
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.
u/semiprocoder 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.
Start a Discussion

b/Hardware

Building a robot, some old-school handheld or other piece of hardware? This is the section to showcase it.

56
Topics
Explore Board
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal