Main Page   Class Hierarchy   Compound List   File List   Contact   Download   Symbolic Constraints   Examples  

ptime.c

00001 #include <stdio.h>
00002 #include <sys/times.h>
00003 #include <time.h>
00004 #include <unistd.h>
00005 
00006 #ifdef PROTOTYPE
00007 float user_time( ) /* returns user-time in seconds */
00008 #else
00009 float user_time( )
00010 #endif
00011 {
00012         struct tms now;
00013         int sec, hun;
00014         float total;
00015 #undef CLK_TCK
00016 #ifndef CLK_TCK
00017         int clocks_per_second = 0;
00018         
00019         clocks_per_second = sysconf( _SC_CLK_TCK );
00020         times( &now );
00021         
00022         hun  = ((now.tms_utime % clocks_per_second)*100)/clocks_per_second;
00023         sec = (now.tms_utime / clocks_per_second);
00024 #else
00025         times( &now );
00026 
00027         hun  = ( ( now.tms_utime % CLK_TCK ) * 100 ) / CLK_TCK;
00028         sec = ( now.tms_utime / CLK_TCK );
00029 #endif
00030 
00031         total = (float)sec + ( (float)(hun) / 100.0 );
00032         
00033         return( total );
00034 }
00035 
00036 
Generated on Mon Mar 28 22:03:49 2011 for SCIL by  doxygen 1.6.3