- 3D-Druck Einstieg und Tipps         
Ergebnis 1 bis 10 von 63

Thema: Farben nach R,G,B umwandeln in 4-stell. hex-code?

Baum-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #30
    HaWe
    Gast
    ja, ich habe ja schon mal einen Benchmarktest für verschiedene MCUs geschrieben, könnte ich mal machen



    - - - Aktualisiert - - -

    edit: Code aktualisiert nach Ceos' Einwand (s.u.!)

    Code:
    #define TimerMS() millis()  //for  cross plattform compatib
    uint32_t time0;
    
    long test_Int_multdiv2() {
      uint32_t  x,y;
      volatile uint32_t  s;
    
      for(y=0;y<10000;y++) {
        s=11;
        for(x=1;x<=16;x++) { s*=2;}
        for(x=16; x>0;x--) { s/=2;}
        s=7;
        for(x=1;x<=8;x++) { s*=8;}
        for(x=8; x>0;x--) { s/=8;}
      }
      return s;
    }
    
    
    long test_Int_shl_shr() {
      uint32_t  x,y;
      volatile uint32_t  s;
    
      for(y=0;y<10000;y++) {
        s=11;
        for(x=1;x<=16;x++) { s=(s<<1);}
        for(x=16; x>0;x--) { s=(s>>1);}
        s=7;
        for(x=1;x<=8;x++) { s=(s<<3);}
        for(x=8; x>0;x--) { s=(s>>3);}
      }
      return s;
    }
    
    
    // *SNIP*
    
    
      time0=TimerMS();
      s=test_Int_multdiv2();
      runtime[0]=TimerMS()-time0;
      sprintf (buf, "%3d %9ld  Int_multdiv2",   0, runtime[0]); Serial.println( buf);
    
    
     time0=TimerMS();
      s=test_Int_shl_shr();
      runtime[1]=TimerMS()-time0;
      sprintf (buf, "%3d %9ld  Int_shl_shr",   1, runtime[1]); Serial.println( buf);
    Ergebnis: doch identisch, anders als vermutet (Angaben in ms):


    Plattform: AVR (Arduino Mega2560, 16 MHz)
    Code:
    start test
      0      1220  Int_multdiv2
      1      1220  Int_shl_shr


    Plattform: ARM Cortex M0 (Adafruit Itsybitsy M0, 48 MHz)
    Code:
    start test
      0        93  Int_multdiv2
      1        93  Int_shl_shr


    Plattform: ARM Cortex M3 (Arduino Due, 84MHz)
    Code:
    start test
      0        49  Int_multdiv2
      1        49  Int_shl_shr


    Pattform: ESP8266 (nodeMCU, Xtensa LX106, 80 MHz)
    Code:
    start test
    start test
      0        56  Int_multdiv2
      1        55  Int_shl_shr
    edit:
    gleiches Ergebnis auch für Zuweisung an 2. Variable:
    Code:
    long test_Int_multdiv2() {
      uint32_t  x,y;
      volatile uint32_t  s,t;
    
      for(y=0;y<10000;y++) {
        s=11;
        for(x=1;x<=16;x++) { t=s*2;}
        for(x=16; x>0;x--) { t=s/2;}
        s=7;
        for(x=1;x<=8;x++) { t=s*8;}
        for(x=8; x>0;x--) { t=s/8;}
      }
      return s;
    }
    
    
    long test_Int_shl_shr() {
      uint32_t  x,y;
      volatile uint32_t  s,t;
    
      for(y=0;y<10000;y++) {
        s=11;
        for(x=1;x<=16;x++) { t=(s<<1);}
        for(x=16; x>0;x--) { t=(s>>1);}
        s=7;
        for(x=1;x<=8;x++) { t=(s<<3);}
        for(x=8; x>0;x--) { t=(s>>3);}
      }
      return s;
    }
    Geändert von HaWe (12.09.2018 um 18:29 Uhr)

Ähnliche Themen

  1. String nach Array umwandeln (?)
    Von slavezero im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 3
    Letzter Beitrag: 07.06.2012, 17:21
  2. Chips die nach Seriell umwandeln
    Von dundee12 im Forum Elektronik
    Antworten: 13
    Letzter Beitrag: 12.08.2010, 09:08
  3. word nach byte umwandeln
    Von magic33 im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 10
    Letzter Beitrag: 21.02.2007, 16:04
  4. C-Code in hex umwandeln
    Von elkokiller im Forum C - Programmierung (GCC u.a.)
    Antworten: 2
    Letzter Beitrag: 16.02.2006, 09:41
  5. PAL-Videosignal irgendwie nach seriell umwandeln?
    Von Trabukh im Forum Elektronik
    Antworten: 39
    Letzter Beitrag: 14.09.2005, 13:15

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

LiFePO4 Speicher Test