static void EMU_CALL gate_transition(struct IOPTIMER_STATE *state) { uint32 c; for(c = 0; c < COUNTERS; c++) { // must be both enabled and gate-enabled if((state->counter[c].mode & 0x41) != 0x41) continue; switch(state->counter[c].mode & 0x6) { case 0x0: // TM_GATE_ON_Count if(state->gate) { counter_start(state, c); } else { counter_stop(state, c); } break; case 0x2: // TM_GATE_ON_ClearStart if(state->gate) { counter_start(state, c); } break; case 0x4: // TM_GATE_ON_Clear_OFF_Start if(state->gate) { counter_stop(state, c); } else { counter_start(state, c); } break; case 0x6: // TM_GATE_ON_Start if(state->gate) { // one-time start: disable gate bit state->counter[c].mode &= ~1; counter_start(state, c); } break; } } }
int main(int argc, char *argv[]){ int i; int j; int k; int *data ; unsigned adj; adj = 32 - ((unsigned)data%32); data = data +adj; data= (int *)malloc(sizeof(int) * (1 <<(WRITE_DATA_SIZE-2)) * 10 +64); int arrary_size = (1 <<(WRITE_DATA_SIZE-2)) * 10; counter_start(); memset(data,0,(1<<(WRITE_DATA_SIZE-2)) * 10); for(j = 1; j<=100; j = j*10){ while(*data < j){ for(k = 0; k<=7;k++){ for (i =k; i<arrary_size;i=i+8){ *(data+i) = *(data+i) +1; } } } printf("%d\n",*data); } counter_stop(); printf("Total time for prog2 is %u s\n",c2-c1) free(data); return 0; }
unsigned readData(int *data, long length){ int i; //iterator counter_start(); for(i=0 ;i<length/8 ;i++){ (*(data + i*8))++; } counter_stop(); return c2-c1; }
int readData(int *data, int size, int slot){ int i,temp; counter_start(); for(i =0;i<size;i++){ (*(data + i * slot))++; } counter_stop(); printf("%d %u\n",slot,c2-c1); return 0; }
unsigned readCache(int *a, long start, long end){ int i; //iterator int tmp; //temp data counter_start(); for(i=start;i<end;i++){ tmp=a[i]; } counter_stop(); return c2-c1; }
int calculateTime(int *data, int log_of_associativity){ unsigned c =0; long dataNumber = 1 << (CACHE_SIZE - log_of_associativity); long dataSize = 1; int associativity = 1 << (log_of_associativity); int i,counter; for(counter = 0; counter < TIMES;counter++){ for(i = 0; i < associativity;i++){ counter_start(); counter_stop(); counter_start(); (*(data + 2 * i * dataNumber))++; counter_stop(); c += c2-c1; } } double times = TIMES * associativity; printf("Cycles for %3d way: %u\n", associativity,c/associativity ); return 0; }
void test_run(void) { NRF_LOG_RAW_INFO("\r\n"); NRF_LOG_INFO("Test is ready. Press any key to run.\r\n"); NRF_LOG_FLUSH(); (void) NRF_LOG_GETCHAR(); counter_start(); nrf_ble_amts_notif_spam(&m_amts); }
int readData(int *data,int initial, int length){ int i,temp; struct timeval sc,tc; unsigned c=0; for(i = 0;i < length / 4; i++){ counter_start(); temp = *(data + i * 4); counter_stop(); c += c2-c1; } printf("%d %d %u\n", initial, initial + length ,c); return 0; }
int readData(int *data,int initial, int length){ int i,temp; struct timeval sc,tc; // gettimeofday(&sc,NULL); counter_start(); for(i = 0;i < length / 4; i++){ temp = *(data + i * 4); } /*gettimeofday(&tc,NULL); unsigned long time = 1000000 * (tc.tv_sec - sc.tv_sec) + tc.tv_usec - sc.tv_usec;*/ counter_stop(); printf("%d %d %u\n", initial, initial + length ,c2-c1); return 0; }
void FreqCountClass::begin(uint16_t msec) { if (msec < 10) return; gate_index = 0; count_msw = 0; count_prev = 0; count_ready = 0; counter_init(); gate_length = timer_init(msec); uint8_t status = SREG; cli(); timer_start(); timer_isr_latency_delay(); counter_start(); SREG = status; }
int com_stat(char *arg) { int nrecs; int tsID; UNUSED(arg); fprintf(stdout, "name=%s\n", all_vars[gl_varID].name); for ( tsID = gl_tsID1; tsID <= gl_tsID2; ++tsID ) { nrecs = streamInqTimestep(gl_streamID, tsID); if ( nrecs == 0 ) { fprintf(stderr, "Timestep %d out of range!\n", tsID+1); break; } else { int i; int nmiss; int gridsize; double fmin = 1.e50 , fmax = -1.e50, fmean = 0; counter_t counter; counter_start(&counter); streamReadVarSlice(gl_streamID, gl_varID, levelID, gl_data, &nmiss); gridsize = gridInqSize(vlistInqVarGrid(gl_vlistID, gl_varID)); for ( i = 0; i < gridsize; ++i ) { if ( gl_data[i] < fmin ) fmin = gl_data[i]; if ( gl_data[i] > fmax ) fmax = gl_data[i]; fmean += gl_data[i]; } fmean /= gridsize; counter_stop(&counter); fprintf(stdout, "timestep=%d %g %g %g (%gs)\n", tsID+1, fmin, fmean, fmax, counter_cputime(counter)); } } return (0); }
void EMU_CALL ioptimer_sw(void *state, uint32 a, uint32 d, uint32 mask) { uint32 c = which_counter(a); struct IOPTIMER_COUNTER *ctr; if(c >= COUNTERS) return; ctr = IOPTIMERSTATE->counter + c; d &= mask; if(c < 3) d &= 0xFFFF; switch(a & 0xC) { case 0x4: ctr->delta = 0; ctr->mode = d; if(d & 0x40) { if((d & 7) != 7) { counter_start(state, c); } } break; case 0x8: ctr->compare = d; if(!ctr->compare) { if(c < 3) { ctr->compare = 0x10000; } else { ctr->compare = 0x100000000; } } // // if this timer was running, recompute the target // if(ctr->delta) { ctr->target = ctr->compare * ((uint64)(IOPTIMERSTATE->hz_sysclock)); ctr->target_is_overflow = 0; if(ctr->counter >= ctr->target) { if(c < 3) { ctr->target = ((uint64)(IOPTIMERSTATE->hz_sysclock)) << 16; } else { ctr->target = ((uint64)(IOPTIMERSTATE->hz_sysclock)) << 32; } ctr->target_is_overflow = 1; } } break; } }
void LongProcessing(void) { int i, j; counter_start(10000); for (i = 0; i < 10000; i++) { for (j = 0; j < 10000; j++) { double x = fabs(sin(j * 100.) + cos(j * 100.)); x = sqrt(x * x); } if (!counter_inc()) break; } counter_stop(); }
static void setup_counter(void) { volatile u32_t delay = 0; counter_dev = device_get_binding("AON_TIMER"); if (!counter_dev) { printk("Timer device not found\n"); return; } counter_start(counter_dev); /* The AON timer runs from the RTC clock at 32KHz (rather than * the system clock which is 32MHz) so we need to spin for a few cycles * to allow the register change to propagate. */ for (delay = 5000; delay--;) { } }