3 * email: daniel.otte@rub.de
14 #include <avr/interrupt.h>
15 #include <avr/pgmspace.h>
17 #include "performance_test.h"
28 uint16_t const_overhead=0;
29 uint16_t int_overhead=0;
35 void calibrateTimer(void){
38 const_overhead = TCNT1;
42 // asm volatile("NOP\n"::); asm volatile("NOP\n"::);
47 void startTimer(uint8_t granularity){
48 TCCR1B = 0; /* stop timer */
53 TIMSK |= _BV(TOIE1); /* enable TOIE1 */
54 TCCR1B = granularity & 0x7; /* start timer */
57 uint64_t stopTimer(void){
58 TCCR1B = 0; /* stop timer */
60 ret = (ovfcounter<<16) | TCNT1;
61 ret -= const_overhead;
62 ret -= ovfcounter * int_overhead;
66 void getOverhead(uint16_t* constoh, uint16_t* intoh){
67 *constoh = const_overhead;
68 *intoh = int_overhead;
71 void print_time_P(PGM_P s, uint64_t t){
74 uart_putstr_P(PSTR("\r\n"));
76 ultoa((unsigned long)t, sv, 10);
77 for(c=strlen(sv); c<11; ++c){
83 void print_overhead(void){
85 uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
86 utoa(const_overhead, str, 10);
87 uart_putstr_P(PSTR("\r\n\tconst overhead: "));
89 utoa(int_overhead, str, 10);
90 uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));