SphinxBase  5prealpha
profile.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1999-2001 Carnegie Mellon University. All rights
4  * reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * This work was supported in part by funding from the Defense Advanced
19  * Research Projects Agency and the National Science Foundation of the
20  * United States of America, and the CMU Sphinx Speech Consortium.
21  *
22  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * ====================================================================
35  *
36  */
37 /*
38  * profile.h -- For timing and event counting.
39  *
40  * **********************************************
41  * CMU ARPA Speech Project
42  *
43  * Copyright (c) 1999 Carnegie Mellon University.
44  * ALL RIGHTS RESERVED.
45  * **********************************************
46  *
47  * HISTORY
48  * $Log: profile.h,v $
49  * Revision 1.10 2005/06/22 03:10:59 arthchan2003
50  * 1, Fixed doxygen documentation, 2, Added keyword.
51  *
52  * Revision 1.5 2005/06/15 04:21:47 archan
53  * 1, Fixed doxygen-documentation, 2, Add keyword such that changes will be logged into a file.
54  *
55  * Revision 1.4 2005/04/25 19:22:48 archan
56  * Refactor out the code of rescoring from lexical tree. Potentially we want to turn off the rescoring if we need.
57  *
58  * Revision 1.3 2005/03/30 01:22:48 archan
59  * Fixed mistakes in last updates. Add
60  *
61  *
62  * 11-Mar-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
63  * Added ptmr_init().
64  *
65  * 19-Jun-97 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
66  * Created from earlier Sphinx-3 version.
67  */
68 
69 
70 #ifndef _LIBUTIL_PROFILE_H_
71 #define _LIBUTIL_PROFILE_H_
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 #if 0
77 } /* Fool Emacs into not indenting things. */
78 #endif
79 
87 #include <stdio.h>
88 
89 /* Win32/WinCE DLL gunk */
90 #include <sphinxbase/sphinxbase_export.h>
91 #include <sphinxbase/prim_type.h>
92 
93 
100 typedef struct {
101  char *name;
104  int32 count;
105 } pctr_t;
106 
115 SPHINXBASE_EXPORT
116 pctr_t* pctr_new (
117  char *name
118  );
119 
124 SPHINXBASE_EXPORT
125 void pctr_reset (pctr_t *ctr
126  );
127 
131 SPHINXBASE_EXPORT
132 void pctr_print(FILE *fp,
133  pctr_t *ctr
134  );
135 
139 SPHINXBASE_EXPORT
140 void pctr_increment (pctr_t *ctr,
141  int32 inc
142  );
143 
147 SPHINXBASE_EXPORT
148 void pctr_free(pctr_t* ctr
149  );
150 
151 
157 typedef struct {
158  const char *name;
160  float64 t_cpu;
161  float64 t_elapsed;
162  float64 t_tot_cpu;
163  float64 t_tot_elapsed;
164  float64 start_cpu;
165  float64 start_elapsed;
166 } ptmr_t;
167 
168 
169 
171 SPHINXBASE_EXPORT
172 void ptmr_start (ptmr_t *tmr
173  );
174 
176 SPHINXBASE_EXPORT
177 void ptmr_stop (ptmr_t *tmr
178  );
179 
181 SPHINXBASE_EXPORT
182 void ptmr_reset (ptmr_t *tmr
183  );
184 
187 SPHINXBASE_EXPORT
188 void ptmr_init (ptmr_t *tmr
189  );
190 
191 
196 SPHINXBASE_EXPORT
197 void ptmr_reset_all (ptmr_t *tmr
198  );
199 
204 SPHINXBASE_EXPORT
205 void ptmr_print_all (FILE *fp,
206  ptmr_t *tmr,
207  float64 norm
208  );
209 
210 
215 SPHINXBASE_EXPORT
216 int32 host_pclk (int32 dummy);
217 
218 
219 /*
220  * Check the native byte-ordering of the machine by writing a magic
221  * number to a temporary file and reading it back. * Return value:
222  * 0 if BIG-ENDIAN, 1 if LITTLE-ENDIAN, -1 if error.
223  */
224 SPHINXBASE_EXPORT
225 int32 host_endian ( void );
226 
227 #ifdef __cplusplus
228 }
229 #endif
230 
231 #endif
SPHINXBASE_EXPORT void ptmr_reset_all(ptmr_t *tmr)
Reset t_cpu, t_elapsed of all timer modules in array tmr[] to 0.0.
Definition: profile.c:282
SPHINXBASE_EXPORT pctr_t * pctr_new(char *name)
operations of pctr_t
Definition: profile.c:108
int32 count
Counter value.
Definition: profile.h:104
SPHINXBASE_EXPORT void ptmr_start(ptmr_t *tmr)
Start timing using tmr.
Definition: profile.c:179
SPHINXBASE_EXPORT int32 host_pclk(int32 dummy)
Return the processor clock speed (in MHz); only available on some machines (Alphas).
float64 t_tot_elapsed
Total elapsed time since creation.
Definition: profile.h:163
Generic timer structures and functions for coarse-grained performance measurements using standard sys...
Definition: profile.h:157
float64 start_elapsed
-— FOR INTERNAL USE ONLY -—
Definition: profile.h:165
float64 start_cpu
-— FOR INTERNAL USE ONLY -—
Definition: profile.h:164
Basic type definitions used in Sphinx.
const char * name
Timer print name; NULL terminates an array of timers.
Definition: profile.h:158
SPHINXBASE_EXPORT void pctr_free(pctr_t *ctr)
Free the counter.
Definition: profile.c:141
SPHINXBASE_EXPORT void pctr_print(FILE *fp, pctr_t *ctr)
Print a counter.
Definition: profile.c:134
float64 t_cpu
CPU time accumulated since most recent reset op.
Definition: profile.h:160
float64 t_tot_cpu
Total CPU time since creation.
Definition: profile.h:162
SPHINXBASE_EXPORT void ptmr_print_all(FILE *fp, ptmr_t *tmr, float64 norm)
Print t_cpu for all timer modules in tmr[], normalized by norm (i.e., t_cpu/norm).
Definition: profile.c:290
SPHINXBASE_EXPORT void pctr_increment(pctr_t *ctr, int32 inc)
Increment a counter.
Definition: profile.c:127
SPHINXBASE_EXPORT void pctr_reset(pctr_t *ctr)
Reset a counter.
Definition: profile.c:120
SPHINXBASE_EXPORT void ptmr_init(ptmr_t *tmr)
Reset tmr-&gt;{t_cpu, t_elapsed, t_tot_cpu, t_tot_elapsed} to 0.0.
Definition: profile.c:272
SPHINXBASE_EXPORT void ptmr_stop(ptmr_t *tmr)
Stop timing and accumulate tmr-&gt;{t_cpu, t_elapsed, t_tot_cpu, t_tot_elapsed}.
Definition: profile.c:216
float64 t_elapsed
Elapsed time accumulated since most recent reset.
Definition: profile.h:161
SPHINXBASE_EXPORT void ptmr_reset(ptmr_t *tmr)
Reset tmr-&gt;{t_cpu, t_elapsed} to 0.0.
Definition: profile.c:264
char * name
Counter print name; NULL terminates array of counters Used by pctr_print_all.
Definition: profile.h:101
Generic event counter for profiling.
Definition: profile.h:100