1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AnalyzeStartupLog.java,v $
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 //_______________________________________________
38 //_______________________________________________
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. */
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 //_________________________________
63 public static void main(java
.lang
.String
[] lCmdLine
)
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");
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");
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;
105 long t_fwk_start
= 0;
108 long t_sfx_start
= 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;
146 java
.lang
.String sLine
= aBuffer
.readLine();
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();
153 if (sLine
.endsWith("| framework (as96863) ::FilterCache::FilterCache : } creation ConfigItem"))
154 t_cfg_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
156 if (sLine
.endsWith("| framework (as96863) ::FilterCache::FilterCache : { reading TypeDetection.xml"))
157 t_fwk_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
159 if (sLine
.endsWith("| framework (as96863) ::FilterCache::FilterCache : } reading TypeDetection.xml"))
160 t_fwk_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
162 if (sLine
.endsWith("{ framework (as96863) ::FilterCFGAccess::impl_loadTypes"))
163 t_types_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
165 if (sLine
.endsWith("} framework (as96863) ::FilterCFGAccess::impl_loadTypes"))
166 t_types_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
168 if (sLine
.endsWith("{ framework (as96863) ::FilterCFGAccess::impl_loadFilters"))
169 t_filters_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
171 if (sLine
.endsWith("} framework (as96863) ::FilterCFGAccess::impl_loadFilters"))
172 t_filters_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
174 if (sLine
.endsWith("{ reading FilterGroup [swriter]"))
175 t_filters_swriter_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
177 if (sLine
.endsWith("} reading FilterGroup [swriter]"))
178 t_filters_swriter_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
180 if (sLine
.endsWith("{ reading FilterGroup [sweb]"))
181 t_filters_sweb_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
183 if (sLine
.endsWith("} reading FilterGroup [sweb]"))
184 t_filters_sweb_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
186 if (sLine
.endsWith("{ reading FilterGroup [sglobal]"))
187 t_filters_sglobal_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
189 if (sLine
.endsWith("} reading FilterGroup [sglobal]"))
190 t_filters_sglobal_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
192 if (sLine
.endsWith("{ reading FilterGroup [scalc]"))
193 t_filters_scalc_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
195 if (sLine
.endsWith("} reading FilterGroup [scalc]"))
196 t_filters_scalc_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
198 if (sLine
.endsWith("{ reading FilterGroup [sdraw]"))
199 t_filters_sdraw_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
201 if (sLine
.endsWith("} reading FilterGroup [sdraw]"))
202 t_filters_sdraw_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
204 if (sLine
.endsWith("{ reading FilterGroup [simpress]"))
205 t_filters_simpress_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
207 if (sLine
.endsWith("} reading FilterGroup [simpress]"))
208 t_filters_simpress_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
210 if (sLine
.endsWith("{ reading FilterGroup [schart]"))
211 t_filters_schart_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
213 if (sLine
.endsWith("} reading FilterGroup [schart]"))
214 t_filters_schart_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
216 if (sLine
.endsWith("{ reading FilterGroup [smath]"))
217 t_filters_smath_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
219 if (sLine
.endsWith("} reading FilterGroup [smath]"))
220 t_filters_smath_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
222 if (sLine
.endsWith("{ framework (as96863) ::FilterCFGAccess::impl_loadDetectors"))
223 t_others_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
225 if (sLine
.endsWith("} framework (as96863) ::FilterCFGAccess::impl_loadContentHandlers"))
226 t_others_end
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
228 if (sLine
.endsWith("} framework (as96863) ::FilterCache::FilterCache"))
229 t_sfx_start
= new java
.lang
.Long(sLine
.substring(0, 6)).longValue();
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() );
237 sOut
.append(t_cfg_start
);
239 sOut
.append(t_cfg_end
);
241 sOut
.append(t_fwk_start
);
243 sOut
.append(t_fwk_end
);
245 sOut
.append(t_sfx_start
);
247 sOut
.append(t_sfx_end
);
249 sOut
.append(t_types_start
);
251 sOut
.append(t_types_end
);
253 sOut
.append(t_filters_start
);
255 sOut
.append(t_filters_end
);
258 sOut
.append(t_filters_swriter_start
);
260 sOut
.append(t_filters_swriter_end
);
262 sOut
.append(t_filters_sweb_start
);
264 sOut
.append(t_filters_sweb_end
);
266 sOut
.append(t_filters_sglobal_start
);
268 sOut
.append(t_filters_sglobal_end
);
270 sOut
.append(t_filters_scalc_start
);
272 sOut
.append(t_filters_scalc_end
);
274 sOut
.append(t_filters_sdraw_start
);
276 sOut
.append(t_filters_sdraw_end
);
278 sOut
.append(t_filters_simpress_start
);
280 sOut
.append(t_filters_simpress_end
);
282 sOut
.append(t_filters_schart_start
);
284 sOut
.append(t_filters_schart_end
);
286 sOut
.append(t_filters_smath_start
);
288 sOut
.append(t_filters_smath_end
);
291 sOut
.append(t_others_start
);
293 sOut
.append(t_others_end
);
295 sOut
.append(t_cfg_end
-t_cfg_start
);
297 sOut
.append(t_fwk_end
-t_fwk_start
);
299 sOut
.append(t_sfx_end
-t_sfx_start
);
301 sOut
.append(t_types_end
-t_types_start
);
303 sOut
.append(t_filters_end
-t_filters_start
);
305 sOut
.append(t_others_end
-t_others_start
);
307 sOut
.append(t_others_end
-t_cfg_start
);
313 java
.io
.FileWriter aCSV
= new java
.io
.FileWriter(sDataFile
);
314 java
.lang
.String sData
= sOut
.toString();
315 aCSV
.write(sData
, 0, sData
.length());
319 catch(java
.lang
.Throwable exAny
)
321 System
.err
.println(exAny
.getMessage());
322 exAny
.printStackTrace();
323 System
.exit(--nExit
);