#include #include #include #define TIME 1000000 unsigned long long get_iterations( unsigned long t_musec ) { unsigned long long n = 0; struct timeval s, e; unsigned long tdiff; gettimeofday( &s, NULL ); while ( 1 ) { n++; gettimeofday( &e, NULL ); tdiff = (e.tv_sec-s.tv_sec)*1000000+(e.tv_usec-s.tv_usec); if ( tdiff >= t_musec ) break; } return n; } int main( int argc, char** argv ) { unsigned long long cur; while ( 1 ) { cur = get_iterations( TIME ); printf( " %20Lu iter./s\n", cur ); } return 0; }