00001 /* 00002 libit - Library for basic source and channel coding functions 00003 Copyright (C) 2005-2006 Vivien Chappelier, Herve Jegou 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 /* 00021 Timer, only for linux 00022 Copyright (C) 2006 Herve Jegou 00023 Thanks to Pierre-Hugues Joalland for the original code 00024 */ 00025 00026 #ifndef __timer_h_ 00027 #define __timer_h_ 00028 00029 #include <sys/time.h> 00030 #include <sys/resource.h> 00031 00032 typedef struct { 00033 unsigned short status; /* timing status : 0 <=> idle, 1 <=> active */ 00034 00035 struct timeval time_now_wall; /* now registered wall time */ 00036 struct timeval time_last_wall; /* last registered wall time */ 00037 double amount_wall; /* amount of wall time */ 00038 00039 struct rusage time_now_cpu; /* now registered cpu (user + syst) time */ 00040 struct rusage time_last_cpu; /* last registered cpu (user + syst) time */ 00041 double amount_user; /* amount of user time */ 00042 double amount_system; /* amount of system time */ 00043 } it_timer_t; 00044 00045 /* Initialization of the timer */ 00046 it_timer_t * timer_new(); 00047 00048 /* Reinitialization of the timer */ 00049 void timer_rtz( it_timer_t * timer ); 00050 00051 /* Free the timer */ 00052 void timer_free( it_timer_t * timer ); 00053 00054 /* Set the timer on or off */ 00055 void timer_on( it_timer_t * timer ); 00056 void timer_off( it_timer_t * timer ); 00057 00058 /* Return the different kind of usages (CPU is system+user)*/ 00059 double timer_wall( it_timer_t * timer ); 00060 double timer_user( it_timer_t * timer ); 00061 double timer_system( it_timer_t * timer ); 00062 double timer_cpu( it_timer_t * timer ); 00063 00064 #endif
|
|