\doxysection{profile.\+c}
\label{profile_8c_source}\index{src/libsphinxbase/util/profile.c@{src/libsphinxbase/util/profile.c}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*\ -\/*-\/\ c-\/basic-\/offset:\ 4;\ indent-\/tabs-\/mode:\ nil\ -\/*-\/\ */}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*\ ====================================================================}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ Copyright\ (c)\ 1999-\/2001\ Carnegie\ Mellon\ University.\ \ All\ rights}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ Redistribution\ and\ use\ in\ source\ and\ binary\ forms,\ with\ or\ without}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ modification,\ are\ permitted\ provided\ that\ the\ following\ conditions}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ are\ met:}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00010\ \textcolor{comment}{\ *\ 1.\ Redistributions\ of\ source\ code\ must\ retain\ the\ above\ copyright}}
\DoxyCodeLine{00011\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer.\ }}
\DoxyCodeLine{00012\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00013\ \textcolor{comment}{\ *\ 2.\ Redistributions\ in\ binary\ form\ must\ reproduce\ the\ above\ copyright}}
\DoxyCodeLine{00014\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer\ in}}
\DoxyCodeLine{00015\ \textcolor{comment}{\ *\ \ \ \ the\ documentation\ and/or\ other\ materials\ provided\ with\ the}}
\DoxyCodeLine{00016\ \textcolor{comment}{\ *\ \ \ \ distribution.}}
\DoxyCodeLine{00017\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00018\ \textcolor{comment}{\ *\ This\ work\ was\ supported\ in\ part\ by\ funding\ from\ the\ Defense\ Advanced\ }}
\DoxyCodeLine{00019\ \textcolor{comment}{\ *\ Research\ Projects\ Agency\ and\ the\ National\ Science\ Foundation\ of\ the\ }}
\DoxyCodeLine{00020\ \textcolor{comment}{\ *\ United\ States\ of\ America,\ and\ the\ CMU\ Sphinx\ Speech\ Consortium.}}
\DoxyCodeLine{00021\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00022\ \textcolor{comment}{\ *\ THIS\ SOFTWARE\ IS\ PROVIDED\ BY\ CARNEGIE\ MELLON\ UNIVERSITY\ \`{}\`{}AS\ IS''\ AND\ }}
\DoxyCodeLine{00023\ \textcolor{comment}{\ *\ ANY\ EXPRESSED\ OR\ IMPLIED\ WARRANTIES,\ INCLUDING,\ BUT\ NOT\ LIMITED\ TO,\ }}
\DoxyCodeLine{00024\ \textcolor{comment}{\ *\ THE\ IMPLIED\ WARRANTIES\ OF\ MERCHANTABILITY\ AND\ FITNESS\ FOR\ A\ PARTICULAR}}
\DoxyCodeLine{00025\ \textcolor{comment}{\ *\ PURPOSE\ ARE\ DISCLAIMED.\ \ IN\ NO\ EVENT\ SHALL\ CARNEGIE\ MELLON\ UNIVERSITY}}
\DoxyCodeLine{00026\ \textcolor{comment}{\ *\ NOR\ ITS\ EMPLOYEES\ BE\ LIABLE\ FOR\ ANY\ DIRECT,\ INDIRECT,\ INCIDENTAL,}}
\DoxyCodeLine{00027\ \textcolor{comment}{\ *\ SPECIAL,\ EXEMPLARY,\ OR\ CONSEQUENTIAL\ DAMAGES\ (INCLUDING,\ BUT\ NOT\ }}
\DoxyCodeLine{00028\ \textcolor{comment}{\ *\ LIMITED\ TO,\ PROCUREMENT\ OF\ SUBSTITUTE\ GOODS\ OR\ SERVICES;\ LOSS\ OF\ USE,\ }}
\DoxyCodeLine{00029\ \textcolor{comment}{\ *\ DATA,\ OR\ PROFITS;\ OR\ BUSINESS\ INTERRUPTION)\ HOWEVER\ CAUSED\ AND\ ON\ ANY\ }}
\DoxyCodeLine{00030\ \textcolor{comment}{\ *\ THEORY\ OF\ LIABILITY,\ WHETHER\ IN\ CONTRACT,\ STRICT\ LIABILITY,\ OR\ TORT\ }}
\DoxyCodeLine{00031\ \textcolor{comment}{\ *\ (INCLUDING\ NEGLIGENCE\ OR\ OTHERWISE)\ ARISING\ IN\ ANY\ WAY\ OUT\ OF\ THE\ USE\ }}
\DoxyCodeLine{00032\ \textcolor{comment}{\ *\ OF\ THIS\ SOFTWARE,\ EVEN\ IF\ ADVISED\ OF\ THE\ POSSIBILITY\ OF\ SUCH\ DAMAGE.}}
\DoxyCodeLine{00033\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00034\ \textcolor{comment}{\ *\ ====================================================================}}
\DoxyCodeLine{00035\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00036\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00037\ \textcolor{comment}{/*}}
\DoxyCodeLine{00038\ \textcolor{comment}{\ *\ profile.c\ -\/-\/\ For\ timing\ and\ event\ counting.}}
\DoxyCodeLine{00039\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00040\ \textcolor{comment}{\ *\ **********************************************}}
\DoxyCodeLine{00041\ \textcolor{comment}{\ *\ CMU\ ARPA\ Speech\ Project}}
\DoxyCodeLine{00042\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00043\ \textcolor{comment}{\ *\ Copyright\ (c)\ 1999\ Carnegie\ Mellon\ University.}}
\DoxyCodeLine{00044\ \textcolor{comment}{\ *\ ALL\ RIGHTS\ RESERVED.}}
\DoxyCodeLine{00045\ \textcolor{comment}{\ *\ **********************************************}}
\DoxyCodeLine{00046\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00047\ \textcolor{comment}{\ *\ HISTORY}}
\DoxyCodeLine{00048\ \textcolor{comment}{\ *\ \$Log:\ profile.c,v\ \$}}
\DoxyCodeLine{00049\ \textcolor{comment}{\ *\ Revision\ 1.7\ \ 2005/06/22\ 03:10:59\ \ arthchan2003}}
\DoxyCodeLine{00050\ \textcolor{comment}{\ *\ 1,\ Fixed\ doxygen\ documentation,\ 2,\ Added\ \ keyword.}}
\DoxyCodeLine{00051\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00052\ \textcolor{comment}{\ *\ Revision\ 1.3\ \ 2005/03/30\ 01:22:48\ \ archan}}
\DoxyCodeLine{00053\ \textcolor{comment}{\ *\ Fixed\ mistakes\ in\ last\ updates.\ Add}}
\DoxyCodeLine{00054\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00055\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00056\ \textcolor{comment}{\ *\ 11-\/Mar-\/1999\ \ M\ K\ Ravishankar\ (rkm@cs.cmu.edu)\ at\ Carnegie\ Mellon\ University}}
\DoxyCodeLine{00057\ \textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ Added\ ptmr\_init().}}
\DoxyCodeLine{00058\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00059\ \textcolor{comment}{\ *\ 19-\/Jun-\/97\ \ \ \ M\ K\ Ravishankar\ (rkm@cs.cmu.edu)\ at\ Carnegie\ Mellon\ University}}
\DoxyCodeLine{00060\ \textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ Created.}}
\DoxyCodeLine{00061\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00062\ }
\DoxyCodeLine{00063\ \textcolor{preprocessor}{\#include\ <config.h>}}
\DoxyCodeLine{00064\ }
\DoxyCodeLine{00065\ \textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{00066\ \textcolor{preprocessor}{\#include\ <stdlib.h>}}
\DoxyCodeLine{00067\ \textcolor{preprocessor}{\#include\ <string.h>}}
\DoxyCodeLine{00068\ }
\DoxyCodeLine{00069\ \textcolor{preprocessor}{\#if\ defined(\_WIN32)\ \&\&\ !defined(\_\_SYMBIAN32\_\_)}}
\DoxyCodeLine{00070\ \textcolor{preprocessor}{\#\ include\ <windows.h>}}
\DoxyCodeLine{00071\ \textcolor{preprocessor}{\#\ ifndef\ \_WIN32\_WCE}}
\DoxyCodeLine{00072\ \textcolor{preprocessor}{\#\ \ include\ <time.h>}}
\DoxyCodeLine{00073\ \textcolor{preprocessor}{\#\ endif}}
\DoxyCodeLine{00074\ \textcolor{preprocessor}{\#elif\ defined(HAVE\_UNISTD\_H)\ }\textcolor{comment}{/*\ I\ know\ this,\ this\ is\ Unix...\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00075\ \textcolor{preprocessor}{\#\ include\ <unistd.h>}}
\DoxyCodeLine{00076\ \textcolor{preprocessor}{\#\ include\ <sys/time.h>}}
\DoxyCodeLine{00077\ \textcolor{preprocessor}{\#\ include\ <sys/resource.h>}}
\DoxyCodeLine{00078\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00080\ \textcolor{preprocessor}{\#ifdef\ \_MSC\_VER}}
\DoxyCodeLine{00081\ \textcolor{preprocessor}{\#pragma\ warning\ (disable:\ 4996)}}
\DoxyCodeLine{00082\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00083\ }
\DoxyCodeLine{00084\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/profile.h"{}}}
\DoxyCodeLine{00085\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/err.h"{}}}
\DoxyCodeLine{00086\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/ckd\_alloc.h"{}}}
\DoxyCodeLine{00087\ }
\DoxyCodeLine{00088\ \textcolor{comment}{/*\ Silvio\ Moioli:\ updated\ to\ use\ Unicode\ */}}
\DoxyCodeLine{00089\ \textcolor{preprocessor}{\#ifdef\ \_WIN32\_WCE}}
\DoxyCodeLine{00090\ DWORD\ unlink(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *filename)}
\DoxyCodeLine{00091\ \{}
\DoxyCodeLine{00092\ \ \ \ \ \ \ \ \ WCHAR\ *wfilename;}
\DoxyCodeLine{00093\ \ \ \ \ \ \ \ \ DWORD\ rv;}
\DoxyCodeLine{00094\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{size\_t}\ len;}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00096\ \ \ \ \ \ \ \ \ len\ =\ mbstowcs(NULL,\ filename,\ 0);}
\DoxyCodeLine{00097\ \ \ \ \ \ \ \ \ wfilename\ =\ ckd\_calloc(len+1,\ \textcolor{keyword}{sizeof}(*wfilename));}
\DoxyCodeLine{00098\ \ \ \ \ \ \ \ \ mbstowcs(wfilename,\ filename,\ len);}
\DoxyCodeLine{00099\ \ \ \ \ \ \ \ \ rv\ =\ DeleteFileW(wfilename);}
\DoxyCodeLine{00100\ \ \ \ \ \ \ \ \ ckd\_free(wfilename);}
\DoxyCodeLine{00101\ }
\DoxyCodeLine{00102\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ rv;}
\DoxyCodeLine{00103\ \}}
\DoxyCodeLine{00104\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00105\ }
\DoxyCodeLine{00106\ pctr\_t\ *}
\DoxyCodeLine{00107\ pctr\_new(\textcolor{keywordtype}{char}\ *nm)}
\DoxyCodeLine{00108\ \{}
\DoxyCodeLine{00109\ \ \ \ \ pctr\_t\ *pc;}
\DoxyCodeLine{00110\ }
\DoxyCodeLine{00111\ \ \ \ \ pc\ =\ ckd\_calloc(1,\ \textcolor{keyword}{sizeof}(pctr\_t));}
\DoxyCodeLine{00112\ \ \ \ \ pc-\/>name\ =\ ckd\_salloc(nm);}
\DoxyCodeLine{00113\ \ \ \ \ pc-\/>count\ =\ 0;}
\DoxyCodeLine{00114\ }
\DoxyCodeLine{00115\ \ \ \ \ \textcolor{keywordflow}{return}\ pc;}
\DoxyCodeLine{00116\ \}}
\DoxyCodeLine{00117\ }
\DoxyCodeLine{00118\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00119\ pctr\_reset(pctr\_t\ *\ ctr)}
\DoxyCodeLine{00120\ \{}
\DoxyCodeLine{00121\ \ \ \ \ ctr-\/>count\ =\ 0;}
\DoxyCodeLine{00122\ \}}
\DoxyCodeLine{00123\ }
\DoxyCodeLine{00124\ }
\DoxyCodeLine{00125\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00126\ pctr\_increment(pctr\_t\ *\ ctr,\ int32\ inc)}
\DoxyCodeLine{00127\ \{}
\DoxyCodeLine{00128\ \ \ \ \ ctr-\/>count\ +=\ inc;}
\DoxyCodeLine{00129\ \ \ \ \ \textcolor{comment}{/*\ \ \ E\_INFO("{}Name\ \%s,\ Count\ \%d,\ inc\ \%d\(\backslash\)n"{},ctr-\/>name,\ ctr-\/>count,\ inc);\ */}}
\DoxyCodeLine{00130\ \}}
\DoxyCodeLine{00131\ }
\DoxyCodeLine{00132\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00133\ pctr\_print(FILE\ *\ fp,\ pctr\_t\ *\ ctr)}
\DoxyCodeLine{00134\ \{}
\DoxyCodeLine{00135\ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}CTR:"{}});}
\DoxyCodeLine{00136\ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}[\%d\ \%s]"{}},\ ctr-\/>count,\ ctr-\/>name);}
\DoxyCodeLine{00137\ \}}
\DoxyCodeLine{00138\ }
\DoxyCodeLine{00139\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00140\ pctr\_free(pctr\_t\ *\ pc)}
\DoxyCodeLine{00141\ \{}
\DoxyCodeLine{00142\ \ \ \ \ \textcolor{keywordflow}{if}\ (pc)\ \{}
\DoxyCodeLine{00143\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (pc-\/>name)}
\DoxyCodeLine{00144\ \ \ \ \ \ \ \ \ \ \ \ \ ckd\_free(pc-\/>name);}
\DoxyCodeLine{00145\ \ \ \ \ \}}
\DoxyCodeLine{00146\ \ \ \ \ ckd\_free(pc);}
\DoxyCodeLine{00147\ \}}
\DoxyCodeLine{00148\ }
\DoxyCodeLine{00149\ }
\DoxyCodeLine{00150\ \textcolor{preprocessor}{\#if\ defined(\_WIN32)\ \&\&\ !defined(GNUWINCE)\ \&\&\ !defined(\_\_SYMBIAN32\_\_)}}
\DoxyCodeLine{00151\ }
\DoxyCodeLine{00152\ \textcolor{preprocessor}{\#define\ TM\_LOWSCALE\ \ \ \ \ 1e-\/7}}
\DoxyCodeLine{00153\ \textcolor{preprocessor}{\#define\ TM\_HIGHSCALE\ \ \ \ (4294967296.0\ *\ TM\_LOWSCALE);}}
\DoxyCodeLine{00154\ }
\DoxyCodeLine{00155\ \textcolor{keyword}{static}\ float64}
\DoxyCodeLine{00156\ make\_sec(FILETIME\ *\ tm)}
\DoxyCodeLine{00157\ \{}
\DoxyCodeLine{00158\ \ \ \ \ float64\ dt;}
\DoxyCodeLine{00159\ }
\DoxyCodeLine{00160\ \ \ \ \ dt\ =\ tm-\/>dwLowDateTime\ *\ TM\_LOWSCALE;}
\DoxyCodeLine{00161\ \ \ \ \ dt\ +=\ tm-\/>dwHighDateTime\ *\ TM\_HIGHSCALE;}
\DoxyCodeLine{00162\ }
\DoxyCodeLine{00163\ \ \ \ \ \textcolor{keywordflow}{return}\ (dt);}
\DoxyCodeLine{00164\ \}}
\DoxyCodeLine{00165\ }
\DoxyCodeLine{00166\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{/*\ NOT\ WINDOWS\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00167\ }
\DoxyCodeLine{00168\ \textcolor{keyword}{static}\ float64}
\DoxyCodeLine{00169\ make\_sec(\textcolor{keyword}{struct}\ timeval\ *s)}
\DoxyCodeLine{00170\ \{}
\DoxyCodeLine{00171\ \ \ \ \ \textcolor{keywordflow}{return}\ (s-\/>tv\_sec\ +\ s-\/>tv\_usec\ *\ 0.000001);}
\DoxyCodeLine{00172\ \}}
\DoxyCodeLine{00173\ }
\DoxyCodeLine{00174\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00175\ }
\DoxyCodeLine{00176\ }
\DoxyCodeLine{00177\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00178\ ptmr\_start(ptmr\_t\ *\ tm)}
\DoxyCodeLine{00179\ \{}
\DoxyCodeLine{00180\ \textcolor{preprocessor}{\#if\ (!\ defined(\_WIN32))\ ||\ defined(GNUWINCE)\ ||\ defined(\_\_SYMBIAN32\_\_)}}
\DoxyCodeLine{00181\ \ \ \ \ \textcolor{keyword}{struct\ }timeval\ e\_start;\ \ \ \ \ \textcolor{comment}{/*\ Elapsed\ time\ */}}
\DoxyCodeLine{00182\ }
\DoxyCodeLine{00183\ \textcolor{preprocessor}{\#if\ (!\ defined(\_HPUX\_SOURCE))\ \ \&\&\ (!\ defined(\_\_SYMBIAN32\_\_))}}
\DoxyCodeLine{00184\ \ \ \ \ \textcolor{keyword}{struct\ }rusage\ start;\ \ \ \ \ \ \ \ \textcolor{comment}{/*\ CPU\ time\ */}}
\DoxyCodeLine{00185\ }
\DoxyCodeLine{00186\ \ \ \ \ \textcolor{comment}{/*\ Unix\ but\ not\ HPUX\ */}}
\DoxyCodeLine{00187\ \ \ \ \ getrusage(RUSAGE\_SELF,\ \&start);}
\DoxyCodeLine{00188\ \ \ \ \ tm-\/>start\_cpu\ =\ make\_sec(\&start.ru\_utime)\ +\ make\_sec(\&start.ru\_stime);}
\DoxyCodeLine{00189\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00190\ \ \ \ \ \textcolor{comment}{/*\ Unix\ +\ HP\ */}}
\DoxyCodeLine{00191\ \ \ \ \ gettimeofday(\&e\_start,\ 0);}
\DoxyCodeLine{00192\ \ \ \ \ tm-\/>start\_elapsed\ =\ make\_sec(\&e\_start);}
\DoxyCodeLine{00193\ \textcolor{preprocessor}{\#elif\ defined(\_WIN32\_WCE)}}
\DoxyCodeLine{00194\ \ \ \ \ \textcolor{comment}{/*\ No\ GetProcessTimes()\ on\ WinCE.\ \ (Note\ CPU\ time\ will\ be\ bogus)\ */}}
\DoxyCodeLine{00195\ \ \ \ \ tm-\/>start\_cpu\ =\ GetTickCount()\ /\ 1000;}
\DoxyCodeLine{00196\ \ \ \ \ tm-\/>start\_elapsed\ =\ GetTickCount()\ /\ 1000;}
\DoxyCodeLine{00197\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00198\ \ \ \ \ HANDLE\ pid;}
\DoxyCodeLine{00199\ \ \ \ \ FILETIME\ t\_create,\ t\_exit,\ kst,\ ust;}
\DoxyCodeLine{00200\ }
\DoxyCodeLine{00201\ \ \ \ \ \textcolor{comment}{/*\ PC\ */}}
\DoxyCodeLine{00202\ \ \ \ \ pid\ =\ GetCurrentProcess();}
\DoxyCodeLine{00203\ \ \ \ \ GetProcessTimes(pid,\ \&t\_create,\ \&t\_exit,\ \&kst,\ \&ust);}
\DoxyCodeLine{00204\ \ \ \ \ tm-\/>start\_cpu\ =\ make\_sec(\&ust)\ +\ make\_sec(\&kst);}
\DoxyCodeLine{00205\ }
\DoxyCodeLine{00206\ \ \ \ \ tm-\/>start\_elapsed\ =\ (float64)\ clock()\ /\ CLOCKS\_PER\_SEC;}
\DoxyCodeLine{00207\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00208\ \}}
\DoxyCodeLine{00209\ }
\DoxyCodeLine{00210\ }
\DoxyCodeLine{00211\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00212\ ptmr\_stop(ptmr\_t\ *\ tm)}
\DoxyCodeLine{00213\ \{}
\DoxyCodeLine{00214\ \ \ \ \ float64\ dt\_cpu,\ dt\_elapsed;}
\DoxyCodeLine{00215\ }
\DoxyCodeLine{00216\ \textcolor{preprocessor}{\#if\ (!\ defined(\_WIN32))\ ||\ defined(GNUWINCE)\ ||\ defined(\_\_SYMBIAN32\_\_)}}
\DoxyCodeLine{00217\ \ \ \ \ \textcolor{keyword}{struct\ }timeval\ e\_stop;\ \ \ \ \ \ \textcolor{comment}{/*\ Elapsed\ time\ */}}
\DoxyCodeLine{00218\ }
\DoxyCodeLine{00219\ \textcolor{preprocessor}{\#if\ (!\ defined(\_HPUX\_SOURCE))\ \ \&\&\ (!\ defined(\_\_SYMBIAN32\_\_))}}
\DoxyCodeLine{00220\ \ \ \ \ \textcolor{keyword}{struct\ }rusage\ stop;\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ CPU\ time\ */}}
\DoxyCodeLine{00221\ }
\DoxyCodeLine{00222\ \ \ \ \ \textcolor{comment}{/*\ Unix\ but\ not\ HPUX\ */}}
\DoxyCodeLine{00223\ \ \ \ \ getrusage(RUSAGE\_SELF,\ \&stop);}
\DoxyCodeLine{00224\ \ \ \ \ dt\_cpu\ =}
\DoxyCodeLine{00225\ \ \ \ \ \ \ \ \ make\_sec(\&stop.ru\_utime)\ +\ make\_sec(\&stop.ru\_stime)\ -\/}
\DoxyCodeLine{00226\ \ \ \ \ \ \ \ \ tm-\/>start\_cpu;}
\DoxyCodeLine{00227\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00228\ \ \ \ \ dt\_cpu\ =\ 0.0;}
\DoxyCodeLine{00229\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00230\ \ \ \ \ \textcolor{comment}{/*\ Unix\ +\ HP\ */}}
\DoxyCodeLine{00231\ \ \ \ \ gettimeofday(\&e\_stop,\ 0);}
\DoxyCodeLine{00232\ \ \ \ \ dt\_elapsed\ =\ (make\_sec(\&e\_stop)\ -\/\ tm-\/>start\_elapsed);}
\DoxyCodeLine{00233\ \textcolor{preprocessor}{\#elif\ defined(\_WIN32\_WCE)}}
\DoxyCodeLine{00234\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ No\ GetProcessTimes()\ on\ WinCE.\ \ (Note\ CPU\ time\ will\ be\ bogus)\ */}}
\DoxyCodeLine{00235\ \ \ \ \ \ \ \ \ dt\_cpu\ =\ GetTickCount()\ /\ 1000\ -\/\ tm-\/>start\_cpu;}
\DoxyCodeLine{00236\ \ \ \ \ \ \ \ \ dt\_elapsed\ =\ GetTickCount()\ /\ 1000\ -\/\ tm-\/>start\_elapsed;}
\DoxyCodeLine{00237\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00238\ \ \ \ \ HANDLE\ pid;}
\DoxyCodeLine{00239\ \ \ \ \ FILETIME\ t\_create,\ t\_exit,\ kst,\ ust;}
\DoxyCodeLine{00240\ }
\DoxyCodeLine{00241\ \ \ \ \ \textcolor{comment}{/*\ PC\ */}}
\DoxyCodeLine{00242\ \ \ \ \ pid\ =\ GetCurrentProcess();}
\DoxyCodeLine{00243\ \ \ \ \ GetProcessTimes(pid,\ \&t\_create,\ \&t\_exit,\ \&kst,\ \&ust);}
\DoxyCodeLine{00244\ \ \ \ \ dt\_cpu\ =\ make\_sec(\&ust)\ +\ make\_sec(\&kst)\ -\/\ tm-\/>start\_cpu;}
\DoxyCodeLine{00245\ \ \ \ \ dt\_elapsed\ =\ ((float64)\ clock()\ /\ CLOCKS\_PER\_SEC)\ -\/\ tm-\/>start\_elapsed;}
\DoxyCodeLine{00246\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00247\ }
\DoxyCodeLine{00248\ \ \ \ \ tm-\/>t\_cpu\ +=\ dt\_cpu;}
\DoxyCodeLine{00249\ \ \ \ \ tm-\/>t\_elapsed\ +=\ dt\_elapsed;}
\DoxyCodeLine{00250\ }
\DoxyCodeLine{00251\ \ \ \ \ tm-\/>t\_tot\_cpu\ +=\ dt\_cpu;}
\DoxyCodeLine{00252\ \ \ \ \ tm-\/>t\_tot\_elapsed\ +=\ dt\_elapsed;}
\DoxyCodeLine{00253\ \}}
\DoxyCodeLine{00254\ }
\DoxyCodeLine{00255\ }
\DoxyCodeLine{00256\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00257\ ptmr\_reset(ptmr\_t\ *\ tm)}
\DoxyCodeLine{00258\ \{}
\DoxyCodeLine{00259\ \ \ \ \ tm-\/>t\_cpu\ =\ 0.0;}
\DoxyCodeLine{00260\ \ \ \ \ tm-\/>t\_elapsed\ =\ 0.0;}
\DoxyCodeLine{00261\ \}}
\DoxyCodeLine{00262\ }
\DoxyCodeLine{00263\ }
\DoxyCodeLine{00264\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00265\ ptmr\_init(ptmr\_t\ *\ tm)}
\DoxyCodeLine{00266\ \{}
\DoxyCodeLine{00267\ \ \ \ \ tm-\/>t\_cpu\ =\ 0.0;}
\DoxyCodeLine{00268\ \ \ \ \ tm-\/>t\_elapsed\ =\ 0.0;}
\DoxyCodeLine{00269\ \ \ \ \ tm-\/>t\_tot\_cpu\ =\ 0.0;}
\DoxyCodeLine{00270\ \ \ \ \ tm-\/>t\_tot\_elapsed\ =\ 0.0;}
\DoxyCodeLine{00271\ \}}
\DoxyCodeLine{00272\ }
\DoxyCodeLine{00273\ }
\DoxyCodeLine{00274\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00275\ ptmr\_reset\_all(ptmr\_t\ *\ tm)}
\DoxyCodeLine{00276\ \{}
\DoxyCodeLine{00277\ \ \ \ \ \textcolor{keywordflow}{for}\ (;\ tm-\/>name;\ tm++)}
\DoxyCodeLine{00278\ \ \ \ \ \ \ \ \ ptmr\_reset(tm);}
\DoxyCodeLine{00279\ \}}
\DoxyCodeLine{00280\ }
\DoxyCodeLine{00281\ }
\DoxyCodeLine{00282\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00283\ ptmr\_print\_all(FILE\ *\ fp,\ ptmr\_t\ *\ tm,\ float64\ norm)}
\DoxyCodeLine{00284\ \{}
\DoxyCodeLine{00285\ \ \ \ \ \textcolor{keywordflow}{if}\ (norm\ !=\ 0.0)\ \{}
\DoxyCodeLine{00286\ \ \ \ \ \ \ \ \ norm\ =\ 1.0\ /\ norm;}
\DoxyCodeLine{00287\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (;\ tm-\/>name;\ tm++)}
\DoxyCodeLine{00288\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(fp,\ \textcolor{stringliteral}{"{}\ \ \%6.2fx\ \%s"{}},\ tm-\/>t\_cpu\ *\ norm,\ tm-\/>name);}
\DoxyCodeLine{00289\ \ \ \ \ \}}
\DoxyCodeLine{00290\ \}}
\DoxyCodeLine{00291\ }
\DoxyCodeLine{00292\ }
\DoxyCodeLine{00293\ int32}
\DoxyCodeLine{00294\ host\_endian(\textcolor{keywordtype}{void})}
\DoxyCodeLine{00295\ \{}
\DoxyCodeLine{00296\ \ \ \ \ FILE\ *fp;}
\DoxyCodeLine{00297\ \ \ \ \ int32\ BYTE\_ORDER\_MAGIC;}
\DoxyCodeLine{00298\ \ \ \ \ \textcolor{keywordtype}{char}\ *file;}
\DoxyCodeLine{00299\ \ \ \ \ \textcolor{keywordtype}{char}\ buf[8];}
\DoxyCodeLine{00300\ \ \ \ \ int32\ k,\ endian;}
\DoxyCodeLine{00301\ }
\DoxyCodeLine{00302\ \ \ \ \ file\ =\ \textcolor{stringliteral}{"{}/tmp/\_\_EnDiAn\_TeSt\_\_"{}};}
\DoxyCodeLine{00303\ }
\DoxyCodeLine{00304\ \ \ \ \ \textcolor{keywordflow}{if}\ ((fp\ =\ fopen(file,\ \textcolor{stringliteral}{"{}wb"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00305\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Failed\ to\ open\ file\ '\%s'\ for\ writing"{}},\ file);}
\DoxyCodeLine{00306\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00307\ \ \ \ \ \}}
\DoxyCodeLine{00308\ }
\DoxyCodeLine{00309\ \ \ \ \ BYTE\_ORDER\_MAGIC\ =\ (int32)\ 0x11223344;}
\DoxyCodeLine{00310\ }
\DoxyCodeLine{00311\ \ \ \ \ k\ =\ (int32)\ BYTE\_ORDER\_MAGIC;}
\DoxyCodeLine{00312\ \ \ \ \ \textcolor{keywordflow}{if}\ (fwrite(\&k,\ \textcolor{keyword}{sizeof}(int32),\ 1,\ fp)\ !=\ 1)\ \{}
\DoxyCodeLine{00313\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Failed\ to\ write\ to\ file\ '\%s'\(\backslash\)n"{}},\ file);}
\DoxyCodeLine{00314\ \ \ \ \ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00315\ \ \ \ \ \ \ \ \ unlink(file);}
\DoxyCodeLine{00316\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00317\ \ \ \ \ \}}
\DoxyCodeLine{00318\ }
\DoxyCodeLine{00319\ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00320\ \ \ \ \ \textcolor{keywordflow}{if}\ ((fp\ =\ fopen(file,\ \textcolor{stringliteral}{"{}rb"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00321\ \ \ \ \ \ \ \ \ E\_ERROR\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ open\ file\ '\%s'\ for\ reading"{}},\ file);}
\DoxyCodeLine{00322\ \ \ \ \ \ \ \ \ unlink(file);}
\DoxyCodeLine{00323\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00324\ \ \ \ \ \}}
\DoxyCodeLine{00325\ \ \ \ \ \textcolor{keywordflow}{if}\ (fread(buf,\ 1,\ \textcolor{keyword}{sizeof}(int32),\ fp)\ !=\ \textcolor{keyword}{sizeof}(int32))\ \{}
\DoxyCodeLine{00326\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Failed\ to\ read\ from\ file\ '\%s'\(\backslash\)n"{}},\ file);}
\DoxyCodeLine{00327\ \ \ \ \ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00328\ \ \ \ \ \ \ \ \ unlink(file);}
\DoxyCodeLine{00329\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00330\ \ \ \ \ \}}
\DoxyCodeLine{00331\ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00332\ \ \ \ \ unlink(file);}
\DoxyCodeLine{00333\ }
\DoxyCodeLine{00334\ \ \ \ \ \textcolor{comment}{/*\ If\ buf[0]\ ==\ lsB\ of\ BYTE\_ORDER\_MAGIC,\ we\ are\ little-\/endian\ */}}
\DoxyCodeLine{00335\ \ \ \ \ endian\ =\ (buf[0]\ ==\ (BYTE\_ORDER\_MAGIC\ \&\ 0x000000ff))\ ?\ 1\ :\ 0;}
\DoxyCodeLine{00336\ }
\DoxyCodeLine{00337\ \ \ \ \ \textcolor{keywordflow}{return}\ (endian);}
\DoxyCodeLine{00338\ \}}

\end{DoxyCode}
