merge the formfield patch from ooo-build
[ooovba.git] / transex3 / source / filter / utils / AnalyzeStartupLog.java
blob51da44738303eac2fee06f6b741ade29f329bbb7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AnalyzeStartupLog.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package com.sun.star.filter.config.tools.utils;
33 //_______________________________________________
34 // imports
35 import java.util.*;
36 import java.lang.*;
38 //_______________________________________________
39 // implementation
40 public class AnalyzeStartupLog
42 private class OperationTime
44 /** name the measured operation. */
45 public java.lang.String sOperation;
47 /** contains the time value, when this operation was started. */
48 public long nStartTime;
50 /** contains the time value, when this operation was finished. */
51 public long nEndTime;
53 /** text inside log file, which identifies the start time value. */
54 public java.lang.String sStartMsg;
56 /** text inside log file, which identifies the end time value. */
57 public java.lang.String sEndMsg;
60 //_________________________________
61 // main
63 public static void main(java.lang.String[] lCmdLine)
65 int nExit = 0;
66 try
68 // analyze command line
69 ConfigHelper aCmdLine = new ConfigHelper("", lCmdLine);
70 java.lang.String sLogDir = aCmdLine.getString("logdir" );
71 java.lang.String sDataFile = aCmdLine.getString("datafile");
73 if (sLogDir == null || sDataFile == null)
75 System.err.println("AnalyzeStartupLog lodir=<dir> datafile=<file>");
76 System.err.println("E.g.: AnalyzeStartupLog lodir=c:\\temp\\logs datafile=c:\\temp\\data.csv");
77 System.exit(--nExit);
80 // get list of all log files
81 boolean bRecursive = true;
82 java.util.Vector lLogs = FileHelper.getSystemFilesFromDir(new java.io.File(sLogDir), bRecursive);
83 if (lLogs == null || lLogs.isEmpty())
85 System.err.println("log dir is empty");
86 System.exit(--nExit);
89 // analyze it
90 java.lang.StringBuffer sOut = new java.lang.StringBuffer(1000);
91 sOut.append("log;t_cfg_start;t_cfg_end;t_fwk_start;t_fwk_end;t_sfx_start;t_sfx_end;t_types_start;t_types_end;t_filters_start;t_filters_end;");
92 sOut.append("t_filters_swriter_start;t_filters_swriter_end;t_filters_sweb_start;t_filters_sweb_end;t_filters_sglobal_start;t_filters_sglobal_end;t_filters_scalc_start;t_filters_scalc_end;t_filters_sdraw_start;t_filters_sdraw_end;t_filters_simpress_start;t_filters_simpress_end;t_filters_schart_start;t_filters_schart_end;t_filters_smath_start;t_filters_smath_end;");
93 sOut.append("t_others_start;t_others_end;d_cfg;d_fwk;d_sfx;d_types;d_filters;d_others;d_complete\n");
95 java.util.Enumeration aIt = lLogs.elements();
96 while (aIt.hasMoreElements())
98 java.io.File aLog = (java.io.File)aIt.nextElement();
99 java.io.FileReader aReader = new java.io.FileReader(aLog);
100 java.io.BufferedReader aBuffer = new java.io.BufferedReader(aReader);
102 long t_cfg_start = 0;
103 long t_cfg_end = 0;
105 long t_fwk_start = 0;
106 long t_fwk_end = 0;
108 long t_sfx_start = 0;
109 long t_sfx_end = 0;
111 long t_types_start = 0;
112 long t_types_end = 0;
114 long t_filters_start = 0;
115 long t_filters_end = 0;
117 long t_filters_swriter_start = 0;
118 long t_filters_swriter_end = 0;
120 long t_filters_sweb_start = 0;
121 long t_filters_sweb_end = 0;
123 long t_filters_sglobal_start = 0;
124 long t_filters_sglobal_end = 0;
126 long t_filters_scalc_start = 0;
127 long t_filters_scalc_end = 0;
129 long t_filters_sdraw_start = 0;
130 long t_filters_sdraw_end = 0;
132 long t_filters_simpress_start = 0;
133 long t_filters_simpress_end = 0;
135 long t_filters_schart_start = 0;
136 long t_filters_schart_end = 0;
138 long t_filters_smath_start = 0;
139 long t_filters_smath_end = 0;
141 long t_others_start = 0;
142 long t_others_end = 0;
144 while (true)
146 java.lang.String sLine = aBuffer.readLine();
147 if (sLine == null)
148 break;
150 if (sLine.endsWith("| framework (as96863) ::FilterCache::FilterCache : { creation ConfigItem [file=standard, version=6, mode=3]"))
151 t_cfg_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
152 else
153 if (sLine.endsWith("| framework (as96863) ::FilterCache::FilterCache : } creation ConfigItem"))
154 t_cfg_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
155 else
156 if (sLine.endsWith("| framework (as96863) ::FilterCache::FilterCache : { reading TypeDetection.xml"))
157 t_fwk_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
158 else
159 if (sLine.endsWith("| framework (as96863) ::FilterCache::FilterCache : } reading TypeDetection.xml"))
160 t_fwk_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
161 else
162 if (sLine.endsWith("{ framework (as96863) ::FilterCFGAccess::impl_loadTypes"))
163 t_types_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
164 else
165 if (sLine.endsWith("} framework (as96863) ::FilterCFGAccess::impl_loadTypes"))
166 t_types_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
167 else
168 if (sLine.endsWith("{ framework (as96863) ::FilterCFGAccess::impl_loadFilters"))
169 t_filters_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
170 else
171 if (sLine.endsWith("} framework (as96863) ::FilterCFGAccess::impl_loadFilters"))
172 t_filters_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
173 else
174 if (sLine.endsWith("{ reading FilterGroup [swriter]"))
175 t_filters_swriter_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
176 else
177 if (sLine.endsWith("} reading FilterGroup [swriter]"))
178 t_filters_swriter_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
179 else
180 if (sLine.endsWith("{ reading FilterGroup [sweb]"))
181 t_filters_sweb_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
182 else
183 if (sLine.endsWith("} reading FilterGroup [sweb]"))
184 t_filters_sweb_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
185 else
186 if (sLine.endsWith("{ reading FilterGroup [sglobal]"))
187 t_filters_sglobal_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
188 else
189 if (sLine.endsWith("} reading FilterGroup [sglobal]"))
190 t_filters_sglobal_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
191 else
192 if (sLine.endsWith("{ reading FilterGroup [scalc]"))
193 t_filters_scalc_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
194 else
195 if (sLine.endsWith("} reading FilterGroup [scalc]"))
196 t_filters_scalc_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
197 else
198 if (sLine.endsWith("{ reading FilterGroup [sdraw]"))
199 t_filters_sdraw_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
200 else
201 if (sLine.endsWith("} reading FilterGroup [sdraw]"))
202 t_filters_sdraw_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
203 else
204 if (sLine.endsWith("{ reading FilterGroup [simpress]"))
205 t_filters_simpress_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
206 else
207 if (sLine.endsWith("} reading FilterGroup [simpress]"))
208 t_filters_simpress_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
209 else
210 if (sLine.endsWith("{ reading FilterGroup [schart]"))
211 t_filters_schart_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
212 else
213 if (sLine.endsWith("} reading FilterGroup [schart]"))
214 t_filters_schart_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
215 else
216 if (sLine.endsWith("{ reading FilterGroup [smath]"))
217 t_filters_smath_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
218 else
219 if (sLine.endsWith("} reading FilterGroup [smath]"))
220 t_filters_smath_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
221 else
222 if (sLine.endsWith("{ framework (as96863) ::FilterCFGAccess::impl_loadDetectors"))
223 t_others_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
224 else
225 if (sLine.endsWith("} framework (as96863) ::FilterCFGAccess::impl_loadContentHandlers"))
226 t_others_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
227 else
228 if (sLine.endsWith("} framework (as96863) ::FilterCache::FilterCache"))
229 t_sfx_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
230 else
231 if (sLine.endsWith("} desktop (lo119109) OfficeWrapper::OfficeWrapper"))
232 t_sfx_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
235 sOut.append(aLog.getName() );
236 sOut.append(";" );
237 sOut.append(t_cfg_start );
238 sOut.append(";" );
239 sOut.append(t_cfg_end );
240 sOut.append(";" );
241 sOut.append(t_fwk_start );
242 sOut.append(";" );
243 sOut.append(t_fwk_end );
244 sOut.append(";" );
245 sOut.append(t_sfx_start );
246 sOut.append(";" );
247 sOut.append(t_sfx_end );
248 sOut.append(";" );
249 sOut.append(t_types_start );
250 sOut.append(";" );
251 sOut.append(t_types_end );
252 sOut.append(";" );
253 sOut.append(t_filters_start );
254 sOut.append(";" );
255 sOut.append(t_filters_end );
256 sOut.append(";" );
258 sOut.append(t_filters_swriter_start );
259 sOut.append(";" );
260 sOut.append(t_filters_swriter_end );
261 sOut.append(";" );
262 sOut.append(t_filters_sweb_start );
263 sOut.append(";" );
264 sOut.append(t_filters_sweb_end );
265 sOut.append(";" );
266 sOut.append(t_filters_sglobal_start );
267 sOut.append(";" );
268 sOut.append(t_filters_sglobal_end );
269 sOut.append(";" );
270 sOut.append(t_filters_scalc_start );
271 sOut.append(";" );
272 sOut.append(t_filters_scalc_end );
273 sOut.append(";" );
274 sOut.append(t_filters_sdraw_start );
275 sOut.append(";" );
276 sOut.append(t_filters_sdraw_end );
277 sOut.append(";" );
278 sOut.append(t_filters_simpress_start );
279 sOut.append(";" );
280 sOut.append(t_filters_simpress_end );
281 sOut.append(";" );
282 sOut.append(t_filters_schart_start );
283 sOut.append(";" );
284 sOut.append(t_filters_schart_end );
285 sOut.append(";" );
286 sOut.append(t_filters_smath_start );
287 sOut.append(";" );
288 sOut.append(t_filters_smath_end );
289 sOut.append(";" );
291 sOut.append(t_others_start );
292 sOut.append(";" );
293 sOut.append(t_others_end );
294 sOut.append(";" );
295 sOut.append(t_cfg_end -t_cfg_start );
296 sOut.append(";" );
297 sOut.append(t_fwk_end -t_fwk_start );
298 sOut.append(";" );
299 sOut.append(t_sfx_end -t_sfx_start );
300 sOut.append(";" );
301 sOut.append(t_types_end -t_types_start );
302 sOut.append(";" );
303 sOut.append(t_filters_end-t_filters_start);
304 sOut.append(";" );
305 sOut.append(t_others_end -t_others_start );
306 sOut.append(";" );
307 sOut.append(t_others_end -t_cfg_start );
308 sOut.append("\n" );
310 aBuffer.close();
313 java.io.FileWriter aCSV = new java.io.FileWriter(sDataFile);
314 java.lang.String sData = sOut.toString();
315 aCSV.write(sData, 0, sData.length());
316 aCSV.flush();
317 aCSV.close();
319 catch(java.lang.Throwable exAny)
321 System.err.println(exAny.getMessage());
322 exAny.printStackTrace();
323 System.exit(--nExit);
326 System.exit(0);