]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - performance_test.c
+A5/1
[avr-crypto-lib.git] / performance_test.c
index 91d4f1cdb5c7164e1ca01ce5a697acd3d152aacc..44b5b7be26b4db9183ea5f0962d0a8e81c74184d 100644 (file)
@@ -1,15 +1,28 @@
 /*
+ * author: Daniel Otte
+ * email:  daniel.otte@rub.de
+ * license: GPLv3
  * 
  * 
- * 
- */
-
+ **/
+#include "config.h"
+#include <string.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <avr/io.h>
 #include <avr/interrupt.h>
+#include <avr/pgmspace.h>
+#include "uart.h"
 #include "performance_test.h"
 
+
+#ifdef ATMEGA644
+       #define TIMSK TIMSK1
+#endif
+
+
+
 uint32_t ovfcounter;
 
 uint16_t const_overhead=0;
@@ -37,7 +50,7 @@ void startTimer(uint8_t granularity){
        ovfcounter = 0;
        TCCR1A = 0x00;
        TIMSK &= 0xC3;
-       TIMSK |= _BV(2); /* enable TOIE1 */
+       TIMSK |= _BV(TOIE1); /* enable TOIE1 */
        TCCR1B = granularity & 0x7;     /* start timer */
 }
 
@@ -55,6 +68,27 @@ void getOverhead(uint16_t* constoh, uint16_t* intoh){
        *intoh   = int_overhead; 
 }
 
+void print_time_P(PGM_P s, uint64_t t){
+       char sv[16];
+       uint8_t c;
+       uart_putstr_P(PSTR("\r\n"));
+       uart_putstr_P(s);
+       ultoa((unsigned long)t, sv, 10);
+       for(c=strlen(sv); c<11; ++c){
+               uart_putc(' ');
+       }
+       uart_putstr(sv);
+}
 
+void print_overhead(void){
+       char str[16];
+       uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
+       utoa(const_overhead, str, 10);
+       uart_putstr_P(PSTR("\r\n\tconst overhead:     "));
+       uart_putstr(str);
+       utoa(int_overhead, str, 10);
+       uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
+       uart_putstr(str);
+}