• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  comp_stats.h  *
3  *                                                                           *
4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5  *                                                                           *
6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7  *  you may not use this file except in compliance with the License.         *
8  *                                                                           *
9  *  You may obtain a copy of the License at                                  *
10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
11  *                                                                           *
12  *  Unless required by applicable law or agreed to in writing, software      *
13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15  *  See the License for the specific language governing permissions and      *
16  *  limitations under the License.                                           *
17  *                                                                           *
18  *---------------------------------------------------------------------------*/
19 
20 #ifndef __COMP_STATS_H__
21 #define __COMP_STATS_H__
22 
23 
24 
25 
26 #include <stdlib.h>
27 #include <stdio.h>
28 
29 #include "pstdio.h"
30 
31 #ifdef _WIN32
32 #include <windows.h>
33 typedef __int64 CS_TIME;
34 typedef __int64 CS_ACC_TIME;
35 #else
36 typedef clock_t CS_TIME;
37 typedef unsigned long CS_ACC_TIME;
38 #endif
39 
40 #ifdef __vxworks
41 /*
42  * the reason to rename the functions is:
43  * Xanavi project required to combine S2G and Solo together, Solo has the same API
44  * duplicate function names are not allowed in VxWorks
45  */
46 #define init_comp_stats init_comp_stats_esr
47 #define dump_comp_stats dump_comp_stats_esr
48 
49 #define init_cs_clock   init_cs_clock_esr
50 #define print_cs_clock  print_cs_clock_esr
51 
52 #define start_cs_clock  start_cs_clock_esr
53 #define end_cs_clock    end_cs_clock_esr
54 
55 #define reset_cs_clock  reset_cs_clock_esr
56 #define reset_cs_clock  reset_cs_clock_esr
57 #define make_cs_clock   make_cs_clock_esr
58 
59 #endif
60 
61 /**
62  * @todo document
63  */
64 typedef struct CS_CLOCK_t
65 {
66   CS_TIME last;
67   CS_ACC_TIME total_time;
68   double clocks_per_msec;
69   int ncalls;
70   int item_count;
71 }
72 CS_CLOCK;
73 
74 /**
75  * @todo document
76  */
77 typedef struct COMP_STATS_t
78 {
79   CS_CLOCK overall_search;
80   CS_CLOCK models;
81   CS_CLOCK fsm_to_hmm;
82   CS_CLOCK hmm_to_fsm;
83   CS_CLOCK internal_hmm;
84   CS_CLOCK epsilon;
85   CS_CLOCK prune;
86   CS_CLOCK front_end;
87   CS_CLOCK word_lookup;
88   CS_CLOCK word_addition;
89   float total_time;   /*in seconds*/
90   CS_CLOCK astar;
91 }
92 COMP_STATS;
93 
94 
95 void reset_cs_clock(CS_CLOCK *clock);
96 void init_cs_clock(CS_CLOCK *c);
97 CS_CLOCK *make_cs_clock(void);
98 
99 #if defined(__cplusplus) && !defined(_ASCPP)
100 extern "C"
101 {
102 #endif
103   COMP_STATS *init_comp_stats(void);
104   void start_cs_clock(CS_CLOCK *clock);
105   void end_cs_clock(CS_CLOCK *c, int count);
106 #if defined(__cplusplus) && !defined(_ASCPP)
107 }
108 #endif
109 
110 void print_cs_clock(CS_CLOCK *c, float num_seconds, PFile* fp, char *prompt, char *item_name);
111 void dump_comp_stats(COMP_STATS *c, PFile* fp);
112 
113 #if USE_COMP_STATS
114 #if defined(__cplusplus) && !defined(_ASCPP)
115 extern "C"
116 {
117 #endif
118   extern COMP_STATS *comp_stats;
119 #if defined(__cplusplus) && !defined(_ASCPP)
120 }
121 #endif
122 #define init_comp_stats1()        init_comp_stats()
123 #define reset_cs_clock1( CLK)     reset_cs_clock( CLK)
124 #define init_cs_clock1( CLK)      init_cs_clock( CLK)
125 #define make_cs_clock1()          make_cs_clock()
126 #define start_cs_clock1( CLK)     start_cs_clock( CLK)
127 #define end_cs_clock1( CLK,CNT)   end_cs_clock( CLK,CNT)
128 #define print_cs_clock1( CLK, NS,FP,PR,IN)  print_cs_clock( CLK, NS,FP,PR,IN)
129 #define dump_comp_stats1( CS,FP)  dump_comp_stats( CS,FP)
130 
131 #else /* not USE_COMP_STATS */
132 
133 #define init_comp_stats1()
134 #define reset_cs_clock1( CLK)
135 #define init_cs_clock1( CLK)
136 #define make_cs_clock1()
137 #define start_cs_clock1( CLK)
138 #define end_cs_clock1( CLK,CNT)
139 #define print_cs_clock1( CLK, NS,FP,PR,IN)
140 #define dump_comp_stats1( CS,FP)
141 #endif
142 
143 #endif
144