|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 package com.nokia.s60tools.swmtanalyser.model; |
|
18 |
|
19 import java.io.File; |
|
20 import java.io.FileNotFoundException; |
|
21 import java.io.FileOutputStream; |
|
22 import java.io.IOException; |
|
23 import java.util.ArrayList; |
|
24 import java.util.Collections; |
|
25 import java.util.HashMap; |
|
26 import java.util.Map; |
|
27 |
|
28 import org.apache.poi.hssf.usermodel.HSSFCell; |
|
29 import org.apache.poi.hssf.usermodel.HSSFCellStyle; |
|
30 import org.apache.poi.hssf.usermodel.HSSFFont; |
|
31 import org.apache.poi.hssf.usermodel.HSSFRichTextString; |
|
32 import org.apache.poi.hssf.usermodel.HSSFRow; |
|
33 import org.apache.poi.hssf.usermodel.HSSFSheet; |
|
34 import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
|
35 import org.apache.poi.hssf.util.HSSFColor; |
|
36 import org.eclipse.core.runtime.IProgressMonitor; |
|
37 import org.eclipse.jface.dialogs.MessageDialog; |
|
38 import org.eclipse.swt.widgets.Display; |
|
39 |
|
40 import com.nokia.s60tools.swmtanalyser.data.ChunksData; |
|
41 import com.nokia.s60tools.swmtanalyser.data.CycleData; |
|
42 import com.nokia.s60tools.swmtanalyser.data.DiskOverview; |
|
43 import com.nokia.s60tools.swmtanalyser.data.GlobalDataChunks; |
|
44 import com.nokia.s60tools.swmtanalyser.data.OverviewData; |
|
45 import com.nokia.s60tools.swmtanalyser.data.ParsedData; |
|
46 import com.nokia.s60tools.swmtanalyser.data.SystemData; |
|
47 import com.nokia.s60tools.swmtanalyser.data.ThreadData; |
|
48 import com.nokia.s60tools.swmtanalyser.data.WindowGroupEventData; |
|
49 import com.nokia.s60tools.util.debug.DbgUtility; |
|
50 |
|
51 /** |
|
52 * Creates Excel when log files exported. |
|
53 * |
|
54 */ |
|
55 public class ExcelCreator { |
|
56 |
|
57 private String fileName; |
|
58 private FileOutputStream out; |
|
59 |
|
60 private HSSFWorkbook wb; |
|
61 private OverviewData ovData; |
|
62 private ArrayList<Integer> constants = new ArrayList<Integer>(); |
|
63 |
|
64 private Map<String, HSSFCellStyle> styles; |
|
65 private ParsedData logData; |
|
66 private Map<String, ArrayList<ThreadData>> heapData = new HashMap<String, ArrayList<ThreadData>> (); |
|
67 private Map<String, ArrayList<GlobalDataChunks>> glodData = new HashMap<String, ArrayList<GlobalDataChunks>> (); |
|
68 private Map<String, ArrayList<ChunksData>> chunkData = new HashMap<String, ArrayList<ChunksData>> (); |
|
69 private Map<String, ThreadData> deltaData = new HashMap<String, ThreadData> (); |
|
70 private Map<String, String> glodDeltaData = new HashMap<String, String> (); |
|
71 private Map<String, String> chunkDeltaData = new HashMap<String, String> (); |
|
72 private ArrayList<String> heapThreads; |
|
73 private ArrayList<String> glodChunks; |
|
74 private ArrayList<String> nonHeapChunks; |
|
75 |
|
76 private long totalHeapSizeChange =0; |
|
77 private long totalFreeCellChange =0; |
|
78 private long totalAllocCellChange =0; |
|
79 private long totalFreeSpaceChange =0; |
|
80 private long totalAllocSpaceChange =0; |
|
81 private long totalSlackSpaceChange =0; |
|
82 private long totalFilesChange =0; |
|
83 private long totalHandlesChange =0; |
|
84 private int j = 0; |
|
85 |
|
86 private static final String NOT_AVAILABLE = "N/A"; |
|
87 |
|
88 /** |
|
89 * Construction |
|
90 * @param fileName |
|
91 */ |
|
92 public ExcelCreator(String fileName) { |
|
93 //create a new workbook |
|
94 wb = new HSSFWorkbook(); |
|
95 this.fileName = fileName; |
|
96 } |
|
97 |
|
98 /** |
|
99 * Set overview data |
|
100 * @param ovdata |
|
101 */ |
|
102 public void setOverviewPageInput(OverviewData ovdata) |
|
103 { |
|
104 this.ovData = ovdata; |
|
105 } |
|
106 |
|
107 /** |
|
108 * Set all the parsed data of log files. |
|
109 * @param cyclesData |
|
110 */ |
|
111 public void setInputCyclesData(ParsedData cyclesData) |
|
112 { |
|
113 this.logData = cyclesData; |
|
114 } |
|
115 |
|
116 /** |
|
117 * The cycle numbers to be skipped when there are more than 254 cycles. |
|
118 * @param constants |
|
119 */ |
|
120 public void setSkipFileConstant(ArrayList<Integer> constants) |
|
121 { |
|
122 this.constants = constants; |
|
123 } |
|
124 |
|
125 private boolean updateMonitor(IProgressMonitor monitor, String message) |
|
126 { |
|
127 if(monitor!=null) |
|
128 monitor.subTask(message); |
|
129 if(monitor.isCanceled()) |
|
130 { |
|
131 monitor.done(); |
|
132 try { |
|
133 out.close(); |
|
134 } catch (IOException e) { |
|
135 e.printStackTrace(); |
|
136 } |
|
137 return false; |
|
138 } |
|
139 return true; |
|
140 } |
|
141 |
|
142 /** |
|
143 * Create a excel document |
|
144 * @param monitor |
|
145 * @return <code>true</code> if document was created successfully <code>false</code> otherwise. |
|
146 */ |
|
147 public boolean createExcel(IProgressMonitor monitor) |
|
148 { |
|
149 |
|
150 File file = new File(fileName); |
|
151 |
|
152 if(file.exists() && !file.delete()){ |
|
153 Runnable p = new Runnable(){ |
|
154 public void run() { |
|
155 MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser", fileName + "file already exists and could not be deleted.\nPlease close it if open and try again."); |
|
156 } |
|
157 }; |
|
158 Display.getDefault().asyncExec(p); |
|
159 return false; |
|
160 } |
|
161 |
|
162 try { |
|
163 out = new FileOutputStream(fileName); |
|
164 } catch (FileNotFoundException e) { |
|
165 Runnable p = new Runnable(){ |
|
166 public void run() { |
|
167 MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser", "Error in creating file " + fileName); |
|
168 } |
|
169 }; |
|
170 Display.getDefault().asyncExec(p); |
|
171 return false; |
|
172 |
|
173 } |
|
174 |
|
175 styles = createStyles(wb); |
|
176 |
|
177 SWMTLogReaderUtils utilsObj = new SWMTLogReaderUtils(); |
|
178 |
|
179 readGlobalDataFromAllCycles(glodData, logData); |
|
180 getFieldDifferencesForAllGlodChunks(glodDeltaData, logData); |
|
181 |
|
182 readChunkDataFromAllCycles(chunkData, logData); |
|
183 getFieldDifferencesForAllChunks(chunkDeltaData, logData); |
|
184 |
|
185 readHeapDataFromAllCycles(heapData, logData); |
|
186 getFieldDifferencesForAllThreads(deltaData, logData); |
|
187 |
|
188 heapThreads = utilsObj.getAllHeapThreads(logData); |
|
189 Collections.sort(heapThreads); |
|
190 |
|
191 if(!updateMonitor(monitor, "Creating overview sheet...")) |
|
192 return false; |
|
193 createOverViewTab(); |
|
194 |
|
195 if(!updateMonitor(monitor, "Creating disk memory sheet...")) |
|
196 return false; |
|
197 createDiskVariationSheet(); |
|
198 |
|
199 if(!updateMonitor(monitor, "Creating global chunks sheet...")) |
|
200 return false; |
|
201 createGlobalChunksSheet(); |
|
202 |
|
203 if(!updateMonitor(monitor, "Creating non heap chunks sheet...")) |
|
204 return false; |
|
205 createNonHeapChunkSheet(); |
|
206 |
|
207 if(!updateMonitor(monitor, "Creating heap size sheet...")) |
|
208 return false; |
|
209 createHeapSizeTab(); |
|
210 |
|
211 if(!updateMonitor(monitor, "Creating heap allocated space sheet...")) |
|
212 return false; |
|
213 createHeapAllocSpaceTab(); |
|
214 |
|
215 if(!updateMonitor(monitor, "Creating heap free space sheet...")) |
|
216 return false; |
|
217 createHeapFreeSpaceTab(); |
|
218 |
|
219 if(!updateMonitor(monitor, "Creating allocated cells sheet...")) |
|
220 return false; |
|
221 createAllocatedCellsTab(); |
|
222 |
|
223 if(!updateMonitor(monitor, "Creating free cells sheet...")) |
|
224 return false; |
|
225 createFreeCellsTab(); |
|
226 |
|
227 if(!updateMonitor(monitor, "Creating free slack sheet...")) |
|
228 return false; |
|
229 createFreeSlackTab(); |
|
230 |
|
231 if(!updateMonitor(monitor, "Creating largest allocated cells sheet...")) |
|
232 return false; |
|
233 createLargestAllocSizeTab(); |
|
234 |
|
235 if(!updateMonitor(monitor, "Creating largest free size sheet...")) |
|
236 return false; |
|
237 createLargestFreeSizeTab(); |
|
238 |
|
239 if(!updateMonitor(monitor, "Creating window groups sheet...")) |
|
240 return false; |
|
241 createWindowGroupSheet(); |
|
242 |
|
243 // write the workbook to the output stream |
|
244 // close our file (don't blow out our file handles |
|
245 try { |
|
246 wb.write(out); |
|
247 out.close(); |
|
248 } catch (IOException err) { |
|
249 err.printStackTrace(); |
|
250 try { |
|
251 out.close(); |
|
252 } catch (IOException e) { |
|
253 e.printStackTrace(); |
|
254 } |
|
255 return false; |
|
256 } |
|
257 |
|
258 return true; |
|
259 } |
|
260 |
|
261 private boolean createOverViewTab() |
|
262 { |
|
263 //create a new sheet |
|
264 HSSFSheet sheet = wb.createSheet(); |
|
265 // declare a row object reference |
|
266 HSSFRow row = null; |
|
267 // declare a cell object reference |
|
268 HSSFCell cell = null; |
|
269 |
|
270 //set the sheet name in Unicode |
|
271 wb.setSheetName(0, "Overview"); |
|
272 |
|
273 row=sheet.createRow(0); |
|
274 //r.setHeight((short)500); |
|
275 |
|
276 cell= row.createCell(0); |
|
277 cell.setCellStyle(styles.get("header")); |
|
278 cell.setCellValue(new HSSFRichTextString("Overview")); |
|
279 |
|
280 row=sheet.createRow(1); |
|
281 cell=row.createCell(0); |
|
282 cell.setCellValue(new HSSFRichTextString("Number of Cycles")); |
|
283 cell=row.createCell(1); |
|
284 cell.setCellStyle(styles.get("cell_number")); |
|
285 |
|
286 CycleData firstCycle = logData.getLogData()[0]; |
|
287 |
|
288 if(ovData.noOfcycles == 1) |
|
289 cell.setCellValue(new HSSFRichTextString(ovData.noOfcycles + " (" + firstCycle.getCycleNumber() + ")")); |
|
290 else |
|
291 cell.setCellValue(ovData.noOfcycles); |
|
292 |
|
293 row=sheet.createRow(2); |
|
294 cell=row.createCell(0); |
|
295 cell.setCellValue(new HSSFRichTextString("Number of Cycles Truncated")); |
|
296 cell=row.createCell(1); |
|
297 cell.setCellValue(constants.size()); |
|
298 |
|
299 row=sheet.createRow(3); |
|
300 cell = row.createCell(0); |
|
301 cell.setCellValue(new HSSFRichTextString("Time Period")); |
|
302 HSSFCell timePeriod = row.createCell(1); |
|
303 |
|
304 row=sheet.createRow(4); |
|
305 cell=row.createCell(0); |
|
306 cell.setCellValue(new HSSFRichTextString("Time Duration")); |
|
307 cell=row.createCell(1); |
|
308 cell.setCellValue(new HSSFRichTextString(ovData.duration + " sec(" + ovData.durationString + ")")); |
|
309 |
|
310 row=sheet.createRow(5); |
|
311 cell=row.createCell(0); |
|
312 cell.setCellValue(new HSSFRichTextString("ROM Checksum")); |
|
313 cell=row.createCell(1); |
|
314 cell.setCellValue(new HSSFRichTextString(firstCycle.getRomCheckSum())); |
|
315 |
|
316 row=sheet.createRow(6); |
|
317 cell=row.createCell(0); |
|
318 cell.setCellValue(new HSSFRichTextString("ROM Version")); |
|
319 cell=row.createCell(1); |
|
320 cell.setCellValue(new HSSFRichTextString(firstCycle.getRomVersion())); |
|
321 |
|
322 sheet.createRow(7); |
|
323 sheet.createRow(8); |
|
324 sheet.createRow(9); |
|
325 |
|
326 row = sheet.createRow(10); |
|
327 cell = row.createCell(0); |
|
328 cell.setCellStyle(styles.get("header2")); |
|
329 cell.setCellValue(new HSSFRichTextString("")); |
|
330 |
|
331 cell = row.createCell(1); |
|
332 cell.setCellStyle(styles.get("header2")); |
|
333 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
334 |
|
335 HSSFRow totalHeapSizeRow = sheet.createRow(11); |
|
336 cell = totalHeapSizeRow.createCell(0); |
|
337 cell.setCellStyle(styles.get("cell_bold")); |
|
338 cell.setCellValue(new HSSFRichTextString("Heap Size")); |
|
339 |
|
340 HSSFRow freeCellRow = sheet.createRow(12); |
|
341 cell = freeCellRow.createCell(0); |
|
342 cell.setCellStyle(styles.get("cell_bold")); |
|
343 cell.setCellValue(new HSSFRichTextString("Free Cell count")); |
|
344 |
|
345 HSSFRow alloCellRow = sheet.createRow(13); |
|
346 cell = alloCellRow.createCell(0); |
|
347 cell.setCellStyle(styles.get("cell_bold")); |
|
348 cell.setCellValue(new HSSFRichTextString("Allocated Cell count")); |
|
349 |
|
350 HSSFRow freeSpaceRow = sheet.createRow(14); |
|
351 cell = freeSpaceRow.createCell(0); |
|
352 cell.setCellStyle(styles.get("cell_bold")); |
|
353 cell.setCellValue(new HSSFRichTextString("Free space")); |
|
354 |
|
355 HSSFRow allocSpaceRow = sheet.createRow(15); |
|
356 cell = allocSpaceRow.createCell(0); |
|
357 cell.setCellStyle(styles.get("cell_bold")); |
|
358 cell.setCellValue(new HSSFRichTextString("Allocated space")); |
|
359 |
|
360 HSSFRow slackSpaceRow = sheet.createRow(16); |
|
361 cell = slackSpaceRow.createCell(0); |
|
362 cell.setCellStyle(styles.get("cell_bold")); |
|
363 cell.setCellValue(new HSSFRichTextString("Slack space")); |
|
364 |
|
365 HSSFRow filesRow = sheet.createRow(17); |
|
366 cell = filesRow.createCell(0); |
|
367 cell.setCellStyle(styles.get("cell_bold")); |
|
368 cell.setCellValue(new HSSFRichTextString("Total files")); |
|
369 |
|
370 HSSFRow psHandlesRow = sheet.createRow(18); |
|
371 cell = psHandlesRow.createCell(0); |
|
372 cell.setCellStyle(styles.get("cell_bold")); |
|
373 cell.setCellValue(new HSSFRichTextString("Total P&S Handles")); |
|
374 |
|
375 sheet.createRow(19); |
|
376 sheet.createRow(20); |
|
377 sheet.createRow(21); |
|
378 sheet.createRow(22); |
|
379 |
|
380 row = sheet.createRow(23); |
|
381 createOverviewFields(row); |
|
382 |
|
383 createDataInOverView(sheet, 24); |
|
384 |
|
385 cell = totalHeapSizeRow.createCell(1); |
|
386 cell.setCellStyle(styles.get("blue_font")); |
|
387 cell.setCellValue(totalHeapSizeChange); |
|
388 |
|
389 cell = freeCellRow.createCell(1); |
|
390 cell.setCellStyle(styles.get("blue_font")); |
|
391 cell.setCellValue(totalFreeCellChange); |
|
392 |
|
393 cell = alloCellRow.createCell(1); |
|
394 cell.setCellStyle(styles.get("blue_font")); |
|
395 cell.setCellValue(totalAllocCellChange); |
|
396 |
|
397 cell = freeSpaceRow.createCell(1); |
|
398 cell.setCellStyle(styles.get("blue_font")); |
|
399 cell.setCellValue(totalFreeSpaceChange); |
|
400 |
|
401 cell = allocSpaceRow.createCell(1); |
|
402 cell.setCellStyle(styles.get("blue_font")); |
|
403 cell.setCellValue(totalAllocSpaceChange); |
|
404 |
|
405 cell = slackSpaceRow.createCell(1); |
|
406 cell.setCellStyle(styles.get("blue_font")); |
|
407 cell.setCellValue(totalSlackSpaceChange); |
|
408 |
|
409 cell = filesRow.createCell(1); |
|
410 cell.setCellStyle(styles.get("blue_font")); |
|
411 cell.setCellValue(totalFilesChange); |
|
412 |
|
413 cell = psHandlesRow.createCell(1); |
|
414 cell.setCellStyle(styles.get("blue_font")); |
|
415 cell.setCellValue(totalHandlesChange); |
|
416 |
|
417 sheet.autoSizeColumn((short)0); |
|
418 sheet.autoSizeColumn((short)1); |
|
419 sheet.autoSizeColumn((short)2); |
|
420 sheet.autoSizeColumn((short)3); |
|
421 sheet.autoSizeColumn((short)4); |
|
422 sheet.autoSizeColumn((short)5); |
|
423 sheet.autoSizeColumn((short)6); |
|
424 sheet.autoSizeColumn((short)7); |
|
425 sheet.autoSizeColumn((short)8); |
|
426 sheet.autoSizeColumn((short)9); |
|
427 sheet.autoSizeColumn((short)10); |
|
428 sheet.autoSizeColumn((short)11); |
|
429 |
|
430 |
|
431 if(ovData.noOfcycles > 1) |
|
432 timePeriod.setCellValue(new HSSFRichTextString(ovData.fromTime + " to " + ovData.toTime)); |
|
433 else |
|
434 timePeriod.setCellValue(new HSSFRichTextString(ovData.fromTime)); |
|
435 |
|
436 return true; |
|
437 } |
|
438 |
|
439 /** |
|
440 * This method creates the sheet for RAM and DISK Memory data. |
|
441 * It shows the variation of RAM and Disk Memory in each cycle. |
|
442 * |
|
443 */ |
|
444 private void createDiskVariationSheet() { |
|
445 //create a new sheet |
|
446 HSSFSheet sheet = wb.createSheet(); |
|
447 // declare a row object reference |
|
448 HSSFRow row = null; |
|
449 HSSFRow description = null; |
|
450 // declare a cell object reference |
|
451 HSSFCell cell = null; |
|
452 |
|
453 //set the sheet name in Unicode |
|
454 wb.setSheetName(1, "RAM and Disk Memory"); |
|
455 |
|
456 row = sheet.createRow(0); |
|
457 //r.setHeight((short)500); |
|
458 |
|
459 cell = row.createCell(0); |
|
460 cell.setCellStyle(styles.get("header")); |
|
461 cell.setCellValue(new HSSFRichTextString("RAM and Disk Memory")); |
|
462 |
|
463 description = sheet.createRow(1); |
|
464 |
|
465 //creates an empty row |
|
466 row = sheet.createRow(2); |
|
467 |
|
468 row = sheet.createRow(3); |
|
469 |
|
470 cell = row.createCell(0); |
|
471 cell.setCellStyle(styles.get("header2")); |
|
472 cell.setCellValue(new HSSFRichTextString("")); |
|
473 |
|
474 addCycleIntervals(row); |
|
475 |
|
476 cell = row.createCell((int)(row.getLastCellNum())); |
|
477 cell.setCellStyle(styles.get("header2")); |
|
478 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
479 |
|
480 SWMTLogReaderUtils utils = new SWMTLogReaderUtils(); |
|
481 ArrayList<String> diskNames = utils.getAllDiskNames(logData); |
|
482 |
|
483 int rowNo = 4; |
|
484 |
|
485 row = sheet.createRow(rowNo); |
|
486 cell = row.createCell(0); |
|
487 cell.setCellStyle(styles.get("cell_normal")); |
|
488 cell.setCellValue(new HSSFRichTextString("RAM (Used)")); |
|
489 |
|
490 ArrayList<SystemData> systemData = utils.getSystemDataFromAllCycles(logData); |
|
491 |
|
492 long [] usedMemValues = new long[logData.getNumberOfCycles()]; |
|
493 |
|
494 j=1; |
|
495 for(int i=0; i<logData.getNumberOfCycles(); i++) |
|
496 { |
|
497 long totalMem = systemData.get(i).getTotalMemory(); |
|
498 long freeMem = systemData.get(i).getFreeMemory(); |
|
499 |
|
500 if(totalMem == -1 || freeMem == -1){ |
|
501 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
502 usedMemValues[i] = -1; |
|
503 } |
|
504 else{ |
|
505 long usedMemory = totalMem - freeMem; |
|
506 usedMemValues[i] = usedMemory; |
|
507 } |
|
508 |
|
509 if(constants.contains(i+1)) |
|
510 continue; |
|
511 |
|
512 cell = row.createCell(j++); |
|
513 cell.setCellStyle(styles.get("cell_number")); |
|
514 cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); |
|
515 |
|
516 if(usedMemValues[i] == -1) |
|
517 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
518 else |
|
519 cell.setCellValue(usedMemValues[i]); |
|
520 |
|
521 //cell.setCellValue(logData.get(i).getFreeMemory()); |
|
522 } |
|
523 |
|
524 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
525 cell.setCellStyle(styles.get("cell_number")); |
|
526 long usedMemChange = utils.calculateDeltaForGivenSet(usedMemValues); |
|
527 |
|
528 cell.setCellValue(usedMemChange); |
|
529 |
|
530 /*cell = row.createCell(logData.size()+1); |
|
531 cell.setCellStyle(styles.get("cell_number")); |
|
532 |
|
533 long firstCycleValue = logData.get(0).getFreeMemory(); |
|
534 long lastCycleValue = logData.get(logData.size()-1).getFreeMemory(); |
|
535 |
|
536 if(firstCycleValue!= -1 && lastCycleValue!= -1) |
|
537 cell.setCellValue(lastCycleValue - firstCycleValue); |
|
538 else{ |
|
539 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
540 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
541 }*/ |
|
542 |
|
543 rowNo++; |
|
544 |
|
545 row = sheet.createRow(rowNo); |
|
546 cell = row.createCell(0); |
|
547 cell.setCellStyle(styles.get("cell_normal")); |
|
548 cell.setCellValue(new HSSFRichTextString("RAM (Size)")); |
|
549 |
|
550 long [] totalMemValues = new long[logData.getNumberOfCycles()]; |
|
551 |
|
552 j=1; |
|
553 for(int i=0; i<logData.getNumberOfCycles(); i++) |
|
554 { |
|
555 long totalMem = systemData.get(i).getTotalMemory(); |
|
556 |
|
557 if(totalMem == -1){ |
|
558 totalMemValues[i] = -1; |
|
559 } |
|
560 else{ |
|
561 totalMemValues[i] = totalMem; |
|
562 } |
|
563 //cell.setCellValue(logData.get(i).getFreeMemory()); |
|
564 |
|
565 if(constants.contains(i+1)) |
|
566 continue; |
|
567 |
|
568 cell = row.createCell(j++); |
|
569 cell.setCellStyle(styles.get("cell_number")); |
|
570 cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); |
|
571 |
|
572 if(totalMemValues[i] == -1) |
|
573 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
574 else |
|
575 cell.setCellValue(totalMemValues[i]); |
|
576 } |
|
577 |
|
578 cell = row.createCell(logData.getNumberOfCycles() + 1 -constants.size()); |
|
579 cell.setCellStyle(styles.get("cell_number")); |
|
580 long totalMemChange = utils.calculateDeltaForGivenSet(totalMemValues); |
|
581 |
|
582 cell.setCellValue(totalMemChange); |
|
583 |
|
584 Collections.sort(diskNames); |
|
585 |
|
586 for(String name:diskNames) |
|
587 { |
|
588 rowNo++; |
|
589 |
|
590 row = sheet.createRow(rowNo); |
|
591 cell = row.createCell(0); |
|
592 cell.setCellStyle(styles.get("cell_normal")); |
|
593 cell.setCellValue(new HSSFRichTextString(name + " (Used)")); |
|
594 |
|
595 ArrayList<DiskOverview> values = utils.getUsedMemoryAndSizesForDisk(name, logData); |
|
596 long [] usedSizes = new long[values.size()]; |
|
597 |
|
598 j=1; |
|
599 for(int i=0; i<values.size(); i++) |
|
600 { |
|
601 if(constants.contains(i+1)) |
|
602 continue; |
|
603 |
|
604 cell = row.createCell(j++); |
|
605 cell.setCellStyle(styles.get("cell_number")); |
|
606 cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); |
|
607 |
|
608 long usedSize = values.get(i).getUsedSize(); |
|
609 |
|
610 if(usedSize == -1){ |
|
611 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
612 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
613 } |
|
614 else |
|
615 cell.setCellValue(usedSize); |
|
616 |
|
617 usedSizes[i] = usedSize; |
|
618 |
|
619 } |
|
620 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
621 cell.setCellStyle(styles.get("cell_number")); |
|
622 long deltaValue = utils.calculateDeltaForGivenSet(usedSizes); |
|
623 |
|
624 cell.setCellValue(deltaValue); |
|
625 rowNo++; |
|
626 |
|
627 row = sheet.createRow(rowNo); |
|
628 cell = row.createCell(0); |
|
629 cell.setCellStyle(styles.get("cell_normal")); |
|
630 cell.setCellValue(new HSSFRichTextString(name + " (Size)")); |
|
631 |
|
632 long [] sizeValues = new long[values.size()]; |
|
633 |
|
634 j=1; |
|
635 for(int i=0; i<values.size(); i++) |
|
636 { |
|
637 if(constants.contains(i+1)) |
|
638 continue; |
|
639 |
|
640 cell = row.createCell(j++); |
|
641 cell.setCellStyle(styles.get("cell_number")); |
|
642 cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); |
|
643 |
|
644 long size = values.get(i).getSize(); |
|
645 |
|
646 if(size == -1){ |
|
647 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
648 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
649 } |
|
650 else |
|
651 cell.setCellValue(size); |
|
652 |
|
653 sizeValues[i] = size; |
|
654 } |
|
655 |
|
656 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
657 cell.setCellStyle(styles.get("cell_number")); |
|
658 long sizeDelta = utils.calculateDeltaForGivenSet(sizeValues); |
|
659 |
|
660 cell.setCellValue(sizeDelta); |
|
661 |
|
662 } |
|
663 |
|
664 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
665 { |
|
666 sheet.autoSizeColumn((short)i); |
|
667 } |
|
668 cell = description.createCell(0); |
|
669 cell.setCellValue(new HSSFRichTextString("Specifies the amount of used RAM and disk memories of all drives in bytes, for each cycle in seconds")); |
|
670 } |
|
671 |
|
672 private void createHeapSizeTab() |
|
673 { |
|
674 HSSFSheet sheet = wb.createSheet(); |
|
675 // declare a row object reference |
|
676 HSSFRow row = null; |
|
677 HSSFRow description = null; |
|
678 // declare a cell object reference |
|
679 HSSFCell cell = null; |
|
680 |
|
681 //set the sheet name in Unicode |
|
682 wb.setSheetName(4, "Total Heap Size"); |
|
683 |
|
684 row = sheet.createRow(0); |
|
685 //r.setHeight((short)500); |
|
686 |
|
687 cell = row.createCell(0); |
|
688 cell.setCellStyle(styles.get("header")); |
|
689 cell.setCellValue(new HSSFRichTextString("Total Heap Size")); |
|
690 |
|
691 description = sheet.createRow(1); |
|
692 |
|
693 //creates an empty row. |
|
694 row = sheet.createRow(2); |
|
695 |
|
696 row = sheet.createRow(3); |
|
697 cell = row.createCell(0); |
|
698 cell.setCellStyle(styles.get("header1")); |
|
699 cell.setCellValue(new HSSFRichTextString("Threads")); |
|
700 addCycleIntervals(row); |
|
701 |
|
702 cell = row.createCell((int)row.getLastCellNum()); |
|
703 cell.setCellStyle(styles.get("header2")); |
|
704 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
705 |
|
706 int rowNo = 4; |
|
707 |
|
708 for(String heap:heapThreads) |
|
709 { |
|
710 row = sheet.createRow(rowNo); |
|
711 cell = row.createCell(0); |
|
712 cell.setCellStyle(styles.get("cell_normal")); |
|
713 cell.setCellValue(new HSSFRichTextString(heap)); |
|
714 |
|
715 ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase()); |
|
716 |
|
717 if(heapValues != null) |
|
718 { |
|
719 int j=1; |
|
720 for(int i=0; i<heapValues.size(); i++) |
|
721 { |
|
722 if(constants.contains(i+1)) |
|
723 { |
|
724 if(heap.equalsIgnoreCase("!SensorServer[1020507e]0001::OrientationThread")) |
|
725 DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Skipping data from Cycle.." + i); |
|
726 continue; |
|
727 } |
|
728 |
|
729 cell = row.createCell(j++); |
|
730 cell.setCellStyle(styles.get("cell_number")); |
|
731 ThreadData thData = heapValues.get(i); |
|
732 |
|
733 if(thData.getStatus() == 0){ |
|
734 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
735 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
736 } |
|
737 else |
|
738 cell.setCellValue(thData.getHeapChunkSize()); |
|
739 } |
|
740 } |
|
741 |
|
742 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
743 cell.setCellStyle(styles.get("cell_number")); |
|
744 |
|
745 ThreadData delta = deltaData.get(heap.toLowerCase()); |
|
746 |
|
747 //DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Delta for the thread " + heap + " is " + delta); |
|
748 |
|
749 if(delta != null){ |
|
750 long heapSizeDelta = delta.getHeapChunkSize(); |
|
751 cell.setCellValue(heapSizeDelta); |
|
752 } |
|
753 else |
|
754 cell.setCellValue(0); |
|
755 |
|
756 rowNo++; |
|
757 } |
|
758 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
759 { |
|
760 sheet.autoSizeColumn((short)i); |
|
761 } |
|
762 cell = description.createCell(0); |
|
763 cell.setCellValue(new HSSFRichTextString("Specifies the total heap size for each thread in bytes, for each cycle in seconds")); |
|
764 } |
|
765 |
|
766 private void createHeapAllocSpaceTab() |
|
767 { |
|
768 HSSFSheet sheet = wb.createSheet(); |
|
769 // declare a row object reference |
|
770 HSSFRow row = null; |
|
771 HSSFRow description = null; |
|
772 // declare a cell object reference |
|
773 HSSFCell cell = null; |
|
774 |
|
775 //set the sheet name in Unicode |
|
776 wb.setSheetName(5, "Total heap alloc space"); |
|
777 |
|
778 row = sheet.createRow(0); |
|
779 //r.setHeight((short)500); |
|
780 |
|
781 cell = row.createCell(0); |
|
782 cell.setCellStyle(styles.get("header")); |
|
783 cell.setCellValue(new HSSFRichTextString("Total Heap Allocated Space")); |
|
784 |
|
785 description = sheet.createRow(1); |
|
786 |
|
787 //creates an empty row. |
|
788 row = sheet.createRow(2); |
|
789 |
|
790 row = sheet.createRow(3); |
|
791 cell = row.createCell(0); |
|
792 cell.setCellStyle(styles.get("header1")); |
|
793 cell.setCellValue(new HSSFRichTextString("Threads")); |
|
794 addCycleIntervals(row); |
|
795 |
|
796 cell = row.createCell((int)row.getLastCellNum()); |
|
797 cell.setCellStyle(styles.get("header2")); |
|
798 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
799 |
|
800 int rowNo = 4; |
|
801 |
|
802 for(String heap:heapThreads) |
|
803 { |
|
804 row = sheet.createRow(rowNo); |
|
805 cell = row.createCell(0); |
|
806 cell.setCellStyle(styles.get("cell_normal")); |
|
807 cell.setCellValue(new HSSFRichTextString(heap)); |
|
808 |
|
809 ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase()); |
|
810 |
|
811 if(heapValues != null) |
|
812 { |
|
813 int j=1; |
|
814 for(int i=0; i<heapValues.size(); i++) |
|
815 { |
|
816 if(constants.contains(i+1)) |
|
817 continue; |
|
818 |
|
819 cell = row.createCell(j++); |
|
820 cell.setCellStyle(styles.get("cell_number")); |
|
821 ThreadData thData = heapValues.get(i); |
|
822 |
|
823 if(thData.getStatus() == 0){ |
|
824 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
825 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
826 } |
|
827 else |
|
828 cell.setCellValue(thData.getHeapAllocatedSpace()); |
|
829 |
|
830 } |
|
831 } |
|
832 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
833 cell.setCellStyle(styles.get("cell_number")); |
|
834 |
|
835 if(deltaData.get(heap.toLowerCase()) != null){ |
|
836 long heapAllocSpaceDelta = deltaData.get(heap.toLowerCase()).getHeapAllocatedSpace(); |
|
837 cell.setCellValue(heapAllocSpaceDelta); |
|
838 } |
|
839 else |
|
840 cell.setCellValue(0); |
|
841 |
|
842 rowNo++; |
|
843 } |
|
844 |
|
845 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
846 { |
|
847 sheet.autoSizeColumn((short)i); |
|
848 } |
|
849 |
|
850 cell = description.createCell(0); |
|
851 cell.setCellValue(new HSSFRichTextString("Specifies the total heap allocated space for each thread in bytes, for each cycle in seconds")); |
|
852 } |
|
853 |
|
854 private void createHeapFreeSpaceTab() |
|
855 { |
|
856 HSSFSheet sheet = wb.createSheet(); |
|
857 // declare a row object reference |
|
858 HSSFRow row = null; |
|
859 HSSFRow description = null; |
|
860 // declare a cell object reference |
|
861 HSSFCell cell = null; |
|
862 |
|
863 //set the sheet name in Unicode |
|
864 wb.setSheetName(6, "Total heap free space"); |
|
865 |
|
866 row = sheet.createRow(0); |
|
867 //r.setHeight((short)500); |
|
868 |
|
869 cell = row.createCell(0); |
|
870 cell.setCellStyle(styles.get("header")); |
|
871 cell.setCellValue(new HSSFRichTextString("Total Heap Free Space")); |
|
872 |
|
873 description = sheet.createRow(1); |
|
874 |
|
875 //creates an empty row. |
|
876 row = sheet.createRow(2); |
|
877 |
|
878 row = sheet.createRow(3); |
|
879 cell = row.createCell(0); |
|
880 cell.setCellStyle(styles.get("header1")); |
|
881 cell.setCellValue(new HSSFRichTextString("Threads")); |
|
882 addCycleIntervals(row); |
|
883 |
|
884 cell = row.createCell((int)row.getLastCellNum()); |
|
885 cell.setCellStyle(styles.get("header2")); |
|
886 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
887 |
|
888 int rowNo = 4; |
|
889 |
|
890 for(String heap:heapThreads) |
|
891 { |
|
892 row = sheet.createRow(rowNo); |
|
893 cell = row.createCell(0); |
|
894 cell.setCellStyle(styles.get("cell_normal")); |
|
895 cell.setCellValue(new HSSFRichTextString(heap)); |
|
896 |
|
897 ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase()); |
|
898 |
|
899 if(heapValues != null) |
|
900 { |
|
901 int j=1; |
|
902 for(int i=0; i<heapValues.size(); i++) |
|
903 { |
|
904 if(constants.contains(i+1)) |
|
905 continue; |
|
906 |
|
907 cell = row.createCell(j++); |
|
908 cell.setCellStyle(styles.get("cell_number")); |
|
909 ThreadData thData = heapValues.get(i); |
|
910 |
|
911 if(thData.getStatus() == 0){ |
|
912 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
913 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
914 } |
|
915 else |
|
916 cell.setCellValue(thData.getHeapFreeSpace()); |
|
917 } |
|
918 } |
|
919 |
|
920 cell = row.createCell(logData.getNumberOfCycles() + 1 -constants.size()); |
|
921 cell.setCellStyle(styles.get("cell_number")); |
|
922 |
|
923 if(deltaData.get(heap.toLowerCase()) != null){ |
|
924 long heapFreeeDelta = deltaData.get(heap.toLowerCase()).getHeapFreeSpace(); |
|
925 cell.setCellValue(heapFreeeDelta); |
|
926 } |
|
927 else |
|
928 cell.setCellValue(0); |
|
929 |
|
930 rowNo++; |
|
931 } |
|
932 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
933 { |
|
934 sheet.autoSizeColumn((short)i); |
|
935 } |
|
936 |
|
937 cell = description.createCell(0); |
|
938 cell.setCellValue(new HSSFRichTextString("Specifies the total heap free space for each thread in bytes, for each cycle in seconds")); |
|
939 } |
|
940 |
|
941 private void createAllocatedCellsTab() |
|
942 { |
|
943 HSSFSheet sheet = wb.createSheet(); |
|
944 // declare a row object reference |
|
945 HSSFRow row = null; |
|
946 HSSFRow description = null; |
|
947 // declare a cell object reference |
|
948 HSSFCell cell = null; |
|
949 |
|
950 //set the sheet name in Unicode |
|
951 wb.setSheetName(7, "Allocated heap cell count"); |
|
952 |
|
953 row = sheet.createRow(0); |
|
954 //r.setHeight((short)500); |
|
955 |
|
956 cell = row.createCell(0); |
|
957 cell.setCellStyle(styles.get("header")); |
|
958 cell.setCellValue(new HSSFRichTextString("Allocated heap cell count")); |
|
959 |
|
960 description = sheet.createRow(1); |
|
961 |
|
962 //creates an empty row. |
|
963 row = sheet.createRow(2); |
|
964 |
|
965 row = sheet.createRow(3); |
|
966 cell = row.createCell(0); |
|
967 cell.setCellStyle(styles.get("header1")); |
|
968 cell.setCellValue(new HSSFRichTextString("Threads")); |
|
969 addCycleIntervals(row); |
|
970 |
|
971 cell = row.createCell((int)row.getLastCellNum()); |
|
972 cell.setCellStyle(styles.get("header2")); |
|
973 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
974 |
|
975 int rowNo = 4; |
|
976 |
|
977 for(String heap:heapThreads) |
|
978 { |
|
979 row = sheet.createRow(rowNo); |
|
980 cell = row.createCell(0); |
|
981 cell.setCellStyle(styles.get("cell_normal")); |
|
982 cell.setCellValue(new HSSFRichTextString(heap)); |
|
983 |
|
984 ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase()); |
|
985 |
|
986 if(heapValues != null) |
|
987 { |
|
988 int j=1; |
|
989 for(int i=0; i<heapValues.size(); i++) |
|
990 { |
|
991 if(constants.contains(i+1)) |
|
992 continue; |
|
993 |
|
994 cell = row.createCell(j++); |
|
995 cell.setCellStyle(styles.get("cell_number")); |
|
996 ThreadData thData = heapValues.get(i); |
|
997 |
|
998 if(thData.getStatus() == 0){ |
|
999 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
1000 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
1001 } |
|
1002 else |
|
1003 cell.setCellValue(thData.getAllocatedCells()); |
|
1004 } |
|
1005 } |
|
1006 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
1007 cell.setCellStyle(styles.get("cell_number")); |
|
1008 |
|
1009 if(deltaData.get(heap.toLowerCase()) != null){ |
|
1010 long allocCellsDelta = deltaData.get(heap.toLowerCase()).getAllocatedCells(); |
|
1011 cell.setCellValue(allocCellsDelta); |
|
1012 } |
|
1013 else |
|
1014 cell.setCellValue(0); |
|
1015 |
|
1016 rowNo++; |
|
1017 } |
|
1018 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
1019 { |
|
1020 sheet.autoSizeColumn((short)i); |
|
1021 } |
|
1022 |
|
1023 cell = description.createCell(0); |
|
1024 cell.setCellValue(new HSSFRichTextString("Specifies the allocated heap cell count for each thread in bytes, for each cycle in seconds")); |
|
1025 } |
|
1026 |
|
1027 private void createFreeCellsTab() |
|
1028 { |
|
1029 HSSFSheet sheet = wb.createSheet(); |
|
1030 // declare a row object reference |
|
1031 HSSFRow row = null; |
|
1032 HSSFRow description = null; |
|
1033 // declare a cell object reference |
|
1034 HSSFCell cell = null; |
|
1035 |
|
1036 //set the sheet name in Unicode |
|
1037 wb.setSheetName(8, "Free heap cell count"); |
|
1038 |
|
1039 row = sheet.createRow(0); |
|
1040 |
|
1041 cell = row.createCell(0); |
|
1042 cell.setCellStyle(styles.get("header")); |
|
1043 cell.setCellValue(new HSSFRichTextString("Free heap cell count")); |
|
1044 |
|
1045 description = sheet.createRow(1); |
|
1046 |
|
1047 //creates an empty row. |
|
1048 row = sheet.createRow(2); |
|
1049 |
|
1050 row = sheet.createRow(3); |
|
1051 cell = row.createCell(0); |
|
1052 cell.setCellStyle(styles.get("header1")); |
|
1053 cell.setCellValue(new HSSFRichTextString("Threads")); |
|
1054 addCycleIntervals(row); |
|
1055 |
|
1056 cell = row.createCell((int)row.getLastCellNum()); |
|
1057 cell.setCellStyle(styles.get("header2")); |
|
1058 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
1059 |
|
1060 int rowNo = 4; |
|
1061 |
|
1062 for(String heap:heapThreads) |
|
1063 { |
|
1064 row = sheet.createRow(rowNo); |
|
1065 cell = row.createCell(0); |
|
1066 cell.setCellStyle(styles.get("cell_normal")); |
|
1067 cell.setCellValue(new HSSFRichTextString(heap)); |
|
1068 |
|
1069 ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase()); |
|
1070 |
|
1071 if(heapValues != null) |
|
1072 { |
|
1073 int j=1; |
|
1074 for(int i=0; i<heapValues.size(); i++) |
|
1075 { |
|
1076 if(constants.contains(i+1)) |
|
1077 continue; |
|
1078 |
|
1079 cell = row.createCell(j++); |
|
1080 cell.setCellStyle(styles.get("cell_number")); |
|
1081 ThreadData thData = heapValues.get(i); |
|
1082 |
|
1083 if(thData.getStatus() == 0){ |
|
1084 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
1085 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
1086 } |
|
1087 else |
|
1088 cell.setCellValue(thData.getFreeCells()); |
|
1089 } |
|
1090 } |
|
1091 |
|
1092 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
1093 cell.setCellStyle(styles.get("cell_number")); |
|
1094 |
|
1095 if(deltaData.get(heap.toLowerCase()) != null){ |
|
1096 long heapFreeCellsDelta = deltaData.get(heap.toLowerCase()).getFreeCells(); |
|
1097 cell.setCellValue(heapFreeCellsDelta); |
|
1098 } |
|
1099 else |
|
1100 cell.setCellValue(0); |
|
1101 |
|
1102 rowNo++; |
|
1103 } |
|
1104 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
1105 { |
|
1106 sheet.autoSizeColumn((short)i); |
|
1107 } |
|
1108 |
|
1109 cell = description.createCell(0); |
|
1110 cell.setCellValue(new HSSFRichTextString("Specifies the free heap cell count for each thread in bytes, for each cycle in seconds")); |
|
1111 } |
|
1112 |
|
1113 private void createFreeSlackTab() |
|
1114 { |
|
1115 HSSFSheet sheet = wb.createSheet(); |
|
1116 // declare a row object reference |
|
1117 HSSFRow row = null; |
|
1118 HSSFRow description = null; |
|
1119 // declare a cell object reference |
|
1120 HSSFCell cell = null; |
|
1121 |
|
1122 //set the sheet name in Unicode |
|
1123 wb.setSheetName(9, "Free Slack"); |
|
1124 |
|
1125 row = sheet.createRow(0); |
|
1126 //r.setHeight((short)500); |
|
1127 |
|
1128 cell = row.createCell(0); |
|
1129 cell.setCellStyle(styles.get("header")); |
|
1130 cell.setCellValue(new HSSFRichTextString("Free slack")); |
|
1131 |
|
1132 description = sheet.createRow(1); |
|
1133 |
|
1134 //creates an empty row. |
|
1135 row = sheet.createRow(2); |
|
1136 |
|
1137 row = sheet.createRow(3); |
|
1138 cell = row.createCell(0); |
|
1139 cell.setCellStyle(styles.get("header1")); |
|
1140 cell.setCellValue(new HSSFRichTextString("Threads")); |
|
1141 addCycleIntervals(row); |
|
1142 |
|
1143 cell = row.createCell((int)row.getLastCellNum()); |
|
1144 cell.setCellStyle(styles.get("header2")); |
|
1145 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
1146 |
|
1147 int rowNo = 4; |
|
1148 |
|
1149 for(String heap:heapThreads) |
|
1150 { |
|
1151 row = sheet.createRow(rowNo); |
|
1152 cell = row.createCell(0); |
|
1153 cell.setCellStyle(styles.get("cell_normal")); |
|
1154 cell.setCellValue(new HSSFRichTextString(heap)); |
|
1155 |
|
1156 ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase()); |
|
1157 |
|
1158 if(heapValues != null) |
|
1159 { |
|
1160 int j=1; |
|
1161 for(int i=0; i<heapValues.size(); i++) |
|
1162 { |
|
1163 if(constants.contains(i+1)) |
|
1164 continue; |
|
1165 |
|
1166 cell = row.createCell(j++); |
|
1167 cell.setCellStyle(styles.get("cell_number")); |
|
1168 ThreadData thData = heapValues.get(i); |
|
1169 |
|
1170 if(thData.getStatus() == 0){ |
|
1171 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
1172 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
1173 } |
|
1174 else |
|
1175 cell.setCellValue(thData.getFreeSlackSize()); |
|
1176 } |
|
1177 } |
|
1178 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
1179 cell.setCellStyle(styles.get("cell_number")); |
|
1180 |
|
1181 if(deltaData.get(heap.toLowerCase()) != null){ |
|
1182 long heapSlackDelta = deltaData.get(heap.toLowerCase()).getFreeSlackSize(); |
|
1183 cell.setCellValue(heapSlackDelta); |
|
1184 } |
|
1185 else |
|
1186 cell.setCellValue(0); |
|
1187 |
|
1188 rowNo++; |
|
1189 } |
|
1190 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
1191 { |
|
1192 sheet.autoSizeColumn((short)i); |
|
1193 } |
|
1194 |
|
1195 cell = description.createCell(0); |
|
1196 cell.setCellValue(new HSSFRichTextString("Specifies the free slack size for each thread in bytes, for each cycle in seconds")); |
|
1197 } |
|
1198 |
|
1199 private void createLargestAllocSizeTab() |
|
1200 { |
|
1201 HSSFSheet sheet = wb.createSheet(); |
|
1202 // declare a row object reference |
|
1203 HSSFRow row = null; |
|
1204 HSSFRow description = null; |
|
1205 // declare a cell object reference |
|
1206 HSSFCell cell = null; |
|
1207 |
|
1208 //set the sheet name in Unicode |
|
1209 wb.setSheetName(10, "Largest allocated cell size in heap"); |
|
1210 |
|
1211 row = sheet.createRow(0); |
|
1212 //r.setHeight((short)500); |
|
1213 |
|
1214 cell = row.createCell(0); |
|
1215 cell.setCellStyle(styles.get("header")); |
|
1216 cell.setCellValue(new HSSFRichTextString("Largest allocated cell size in heap")); |
|
1217 |
|
1218 sheet.autoSizeColumn((short)0); |
|
1219 |
|
1220 description = sheet.createRow(1); |
|
1221 |
|
1222 //creates an empty row. |
|
1223 row = sheet.createRow(2); |
|
1224 |
|
1225 row = sheet.createRow(3); |
|
1226 cell = row.createCell(0); |
|
1227 cell.setCellStyle(styles.get("header1")); |
|
1228 cell.setCellValue(new HSSFRichTextString("Threads")); |
|
1229 addCycleIntervals(row); |
|
1230 |
|
1231 cell = row.createCell((int)row.getLastCellNum()); |
|
1232 cell.setCellStyle(styles.get("header2")); |
|
1233 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
1234 |
|
1235 int rowNo = 4; |
|
1236 |
|
1237 for(String heap:heapThreads) |
|
1238 { |
|
1239 row = sheet.createRow(rowNo); |
|
1240 cell = row.createCell(0); |
|
1241 cell.setCellStyle(styles.get("cell_normal")); |
|
1242 cell.setCellValue(new HSSFRichTextString(heap)); |
|
1243 |
|
1244 ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase()); |
|
1245 |
|
1246 if(heapValues != null) |
|
1247 { |
|
1248 int j=1; |
|
1249 for(int i=0; i<heapValues.size(); i++) |
|
1250 { |
|
1251 if(constants.contains(i+1)) |
|
1252 continue; |
|
1253 |
|
1254 cell = row.createCell(j++); |
|
1255 cell.setCellStyle(styles.get("cell_number")); |
|
1256 ThreadData thData = heapValues.get(i); |
|
1257 |
|
1258 if(thData.getStatus() == 0){ |
|
1259 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
1260 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
1261 } |
|
1262 else |
|
1263 cell.setCellValue(thData.getLargestAllocCellSize()); |
|
1264 } |
|
1265 } |
|
1266 cell = row.createCell(logData.getNumberOfCycles() + 1 -constants.size()); |
|
1267 cell.setCellStyle(styles.get("cell_number")); |
|
1268 |
|
1269 if(deltaData.get(heap.toLowerCase()) != null){ |
|
1270 long largetAllocCellDelta = deltaData.get(heap.toLowerCase()).getLargestAllocCellSize(); |
|
1271 cell.setCellValue(largetAllocCellDelta); |
|
1272 } |
|
1273 else |
|
1274 cell.setCellValue(0); |
|
1275 |
|
1276 rowNo++; |
|
1277 } |
|
1278 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
1279 { |
|
1280 sheet.autoSizeColumn((short)i); |
|
1281 } |
|
1282 |
|
1283 cell = description.createCell(0); |
|
1284 cell.setCellValue(new HSSFRichTextString("Specifies the largest allocated cell size in heap for each thread in bytes, for each cycle in seconds")); |
|
1285 } |
|
1286 |
|
1287 private void createLargestFreeSizeTab() |
|
1288 { |
|
1289 HSSFSheet sheet = wb.createSheet(); |
|
1290 // declare a row object reference |
|
1291 HSSFRow row = null; |
|
1292 HSSFRow description = null; |
|
1293 // declare a cell object reference |
|
1294 HSSFCell cell = null; |
|
1295 |
|
1296 //set the sheet name in Unicode |
|
1297 wb.setSheetName(11, "Largest free cell size in heap"); |
|
1298 |
|
1299 row = sheet.createRow(0); |
|
1300 //r.setHeight((short)500); |
|
1301 |
|
1302 cell = row.createCell(0); |
|
1303 cell.setCellStyle(styles.get("header")); |
|
1304 cell.setCellValue(new HSSFRichTextString("Largest free cell size in heap")); |
|
1305 |
|
1306 description = sheet.createRow(1); |
|
1307 |
|
1308 //creates an empty row. |
|
1309 row = sheet.createRow(2); |
|
1310 |
|
1311 row = sheet.createRow(3); |
|
1312 cell = row.createCell(0); |
|
1313 cell.setCellStyle(styles.get("header1")); |
|
1314 cell.setCellValue(new HSSFRichTextString("Threads")); |
|
1315 addCycleIntervals(row); |
|
1316 |
|
1317 cell = row.createCell((int)row.getLastCellNum()); |
|
1318 cell.setCellStyle(styles.get("header2")); |
|
1319 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
1320 |
|
1321 int rowNo = 4; |
|
1322 |
|
1323 for(String heap:heapThreads) |
|
1324 { |
|
1325 row = sheet.createRow(rowNo); |
|
1326 cell = row.createCell(0); |
|
1327 cell.setCellStyle(styles.get("cell_normal")); |
|
1328 cell.setCellValue(new HSSFRichTextString(heap)); |
|
1329 |
|
1330 ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase()); |
|
1331 |
|
1332 if(heapValues != null) |
|
1333 { |
|
1334 int j=1; |
|
1335 for(int i=0; i<heapValues.size(); i++) |
|
1336 { |
|
1337 if(constants.contains(i+1)) |
|
1338 continue; |
|
1339 |
|
1340 cell = row.createCell(j++); |
|
1341 cell.setCellStyle(styles.get("cell_number")); |
|
1342 ThreadData thData = heapValues.get(i); |
|
1343 |
|
1344 if(thData.getStatus() == 0){ |
|
1345 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
1346 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
1347 } |
|
1348 else |
|
1349 cell.setCellValue(thData.getLargestFreeCellSize()); |
|
1350 } |
|
1351 } |
|
1352 |
|
1353 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
1354 cell.setCellStyle(styles.get("cell_number")); |
|
1355 |
|
1356 if(deltaData.get(heap.toLowerCase()) != null){ |
|
1357 long largestFreeCellDelta = deltaData.get(heap.toLowerCase()).getLargestFreeCellSize(); |
|
1358 cell.setCellValue(largestFreeCellDelta); |
|
1359 } |
|
1360 else |
|
1361 cell.setCellValue(0); |
|
1362 |
|
1363 rowNo++; |
|
1364 } |
|
1365 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
1366 { |
|
1367 sheet.autoSizeColumn((short)i); |
|
1368 } |
|
1369 |
|
1370 cell = description.createCell(0); |
|
1371 cell.setCellValue(new HSSFRichTextString("Specifies the largest free cell size in heap for each thread in bytes, for each cycle in seconds")); |
|
1372 } |
|
1373 |
|
1374 /** |
|
1375 * This method creates the sheet for Global Data. |
|
1376 * |
|
1377 * |
|
1378 */ |
|
1379 private void createGlobalChunksSheet() |
|
1380 { |
|
1381 HSSFSheet sheet = wb.createSheet(); |
|
1382 // declare a row object reference |
|
1383 HSSFRow row = null; |
|
1384 HSSFRow description = null; |
|
1385 // declare a cell object reference |
|
1386 HSSFCell cell = null; |
|
1387 |
|
1388 //set the sheet name in Unicode |
|
1389 wb.setSheetName(2, "Global Data"); |
|
1390 |
|
1391 row = sheet.createRow(0); |
|
1392 //r.setHeight((short)500); |
|
1393 |
|
1394 cell = row.createCell(0); |
|
1395 cell.setCellStyle(styles.get("header")); |
|
1396 cell.setCellValue(new HSSFRichTextString("Global Data")); |
|
1397 |
|
1398 description = sheet.createRow(1); |
|
1399 |
|
1400 //creates an empty row. |
|
1401 row = sheet.createRow(2); |
|
1402 |
|
1403 row = sheet.createRow(3); |
|
1404 cell = row.createCell(0); |
|
1405 cell.setCellStyle(styles.get("header1")); |
|
1406 cell.setCellValue(new HSSFRichTextString("Chunk Names")); |
|
1407 addCycleIntervals(row); |
|
1408 |
|
1409 cell = row.createCell((int)row.getLastCellNum()); |
|
1410 cell.setCellStyle(styles.get("header2")); |
|
1411 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
1412 |
|
1413 int rowNo = 4; |
|
1414 |
|
1415 for(String heap:glodChunks) |
|
1416 { |
|
1417 row = sheet.createRow(rowNo); |
|
1418 cell = row.createCell(0); |
|
1419 cell.setCellStyle(styles.get("cell_normal")); |
|
1420 cell.setCellValue(new HSSFRichTextString(heap)); |
|
1421 |
|
1422 ArrayList<GlobalDataChunks> heapValues = glodData.get(heap); |
|
1423 |
|
1424 int j=1; |
|
1425 for(int i=0; i<heapValues.size(); i++) |
|
1426 { |
|
1427 if(constants.contains(i+1)) |
|
1428 continue; |
|
1429 |
|
1430 cell = row.createCell(j++); |
|
1431 cell.setCellStyle(styles.get("cell_number")); |
|
1432 GlobalDataChunks thData = heapValues.get(i); |
|
1433 |
|
1434 if(thData.getAttrib() == 0){ |
|
1435 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
1436 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
1437 } |
|
1438 else |
|
1439 cell.setCellValue(thData.getSize()); |
|
1440 } |
|
1441 |
|
1442 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
1443 cell.setCellStyle(styles.get("cell_number")); |
|
1444 |
|
1445 if(glodDeltaData.get(heap) != null){ |
|
1446 long largestFreeCellDelta = Long.parseLong(glodDeltaData.get(heap)); |
|
1447 cell.setCellValue(largestFreeCellDelta); |
|
1448 } |
|
1449 rowNo++; |
|
1450 } |
|
1451 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
1452 { |
|
1453 sheet.autoSizeColumn((short)i); |
|
1454 } |
|
1455 |
|
1456 cell = description.createCell(0); |
|
1457 cell.setCellValue(new HSSFRichTextString("Specifies the chunk sizes in bytes that caontains global data, for each cycle in seconds")); |
|
1458 |
|
1459 } |
|
1460 |
|
1461 private void createNonHeapChunkSheet() |
|
1462 { |
|
1463 //create a new sheet |
|
1464 HSSFSheet sheet = wb.createSheet(); |
|
1465 // declare a row object reference |
|
1466 HSSFRow row = null; |
|
1467 HSSFRow description = null; |
|
1468 // declare a cell object reference |
|
1469 HSSFCell cell = null; |
|
1470 |
|
1471 //set the sheet name in Unicode |
|
1472 wb.setSheetName(3, "Non-heap chunks"); |
|
1473 |
|
1474 row = sheet.createRow(0); |
|
1475 //r.setHeight((short)500); |
|
1476 |
|
1477 cell = row.createCell(0); |
|
1478 cell.setCellStyle(styles.get("header")); |
|
1479 cell.setCellValue(new HSSFRichTextString("Non-Heap Chunk Size")); |
|
1480 |
|
1481 description = sheet.createRow(1); |
|
1482 |
|
1483 //creates an empty row |
|
1484 row = sheet.createRow(2); |
|
1485 |
|
1486 row = sheet.createRow(3); |
|
1487 cell = row.createCell(0); |
|
1488 cell.setCellStyle(styles.get("header2")); |
|
1489 cell.setCellValue(new HSSFRichTextString("Chunk Names")); |
|
1490 addCycleIntervals(row); |
|
1491 |
|
1492 cell = row.createCell((int)row.getLastCellNum()); |
|
1493 cell.setCellStyle(styles.get("header2")); |
|
1494 cell.setCellValue(new HSSFRichTextString("Delta")); |
|
1495 |
|
1496 int rowNo = 4; |
|
1497 |
|
1498 for(String heap:nonHeapChunks) |
|
1499 { |
|
1500 row = sheet.createRow(rowNo); |
|
1501 cell = row.createCell(0); |
|
1502 cell.setCellStyle(styles.get("cell_normal")); |
|
1503 cell.setCellValue(new HSSFRichTextString(heap)); |
|
1504 |
|
1505 ArrayList<ChunksData> chunkValues = chunkData.get(heap); |
|
1506 |
|
1507 int j=1; |
|
1508 for(int i=0; i<chunkValues.size(); i++) |
|
1509 { |
|
1510 if(constants.contains(i+1)) |
|
1511 continue; |
|
1512 |
|
1513 cell = row.createCell(j++); |
|
1514 cell.setCellStyle(styles.get("cell_number")); |
|
1515 ChunksData chData = chunkValues.get(i); |
|
1516 |
|
1517 if(chData.getAttrib() == 0){ |
|
1518 //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
1519 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
1520 } |
|
1521 else |
|
1522 cell.setCellValue(chData.getSize()); |
|
1523 } |
|
1524 |
|
1525 cell = row.createCell(logData.getNumberOfCycles()+1-constants.size()); |
|
1526 cell.setCellStyle(styles.get("cell_number")); |
|
1527 |
|
1528 if(chunkDeltaData.get(heap) != null){ |
|
1529 long largestFreeCellDelta = Long.parseLong(chunkDeltaData.get(heap)); |
|
1530 cell.setCellValue(largestFreeCellDelta); |
|
1531 } |
|
1532 rowNo++; |
|
1533 } |
|
1534 |
|
1535 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
1536 { |
|
1537 sheet.autoSizeColumn((short)i); |
|
1538 } |
|
1539 |
|
1540 cell = description.createCell(0); |
|
1541 cell.setCellValue(new HSSFRichTextString("Specifies the non heap chunk sizes in bytes, for each cycle in seconds")); |
|
1542 } |
|
1543 |
|
1544 /** |
|
1545 * This method creates sheet with Window Group events. |
|
1546 * |
|
1547 */ |
|
1548 private void createWindowGroupSheet() |
|
1549 { |
|
1550 //create a new sheet |
|
1551 HSSFSheet sheet = wb.createSheet(); |
|
1552 // declare a row object reference |
|
1553 HSSFRow row = null; |
|
1554 HSSFRow description = null; |
|
1555 // declare a cell object reference |
|
1556 HSSFCell cell = null; |
|
1557 |
|
1558 //set the sheet name in Unicode |
|
1559 wb.setSheetName(12, "Window Groups"); |
|
1560 |
|
1561 row = sheet.createRow(0); |
|
1562 //r.setHeight((short)500); |
|
1563 |
|
1564 cell = row.createCell(0); |
|
1565 cell.setCellStyle(styles.get("header")); |
|
1566 cell.setCellValue(new HSSFRichTextString("Window Group Events")); |
|
1567 |
|
1568 description = sheet.createRow(1); |
|
1569 |
|
1570 //creates an empty row |
|
1571 row = sheet.createRow(2); |
|
1572 |
|
1573 row = sheet.createRow(3); |
|
1574 cell = row.createCell(0); |
|
1575 cell.setCellStyle(styles.get("header2")); |
|
1576 cell.setCellValue(new HSSFRichTextString("Window Group Names")); |
|
1577 addCycleIntervals(row); |
|
1578 |
|
1579 SWMTLogReaderUtils utils = new SWMTLogReaderUtils(); |
|
1580 ArrayList<String> wndg_names = utils.getWindowGroupNames(logData); |
|
1581 |
|
1582 int rowNo = 4; |
|
1583 |
|
1584 if(wndg_names == null) |
|
1585 return; |
|
1586 else |
|
1587 { |
|
1588 for(String name:wndg_names) |
|
1589 { |
|
1590 row = sheet.createRow(rowNo++); |
|
1591 cell = row.createCell(0); |
|
1592 cell.setCellStyle(styles.get("cell_normal")); |
|
1593 cell.setCellValue(new HSSFRichTextString(name)); |
|
1594 |
|
1595 ArrayList<WindowGroupEventData> events_list = utils.getAllWindowGroupEvents(name, logData); |
|
1596 |
|
1597 int j = 1; |
|
1598 |
|
1599 for(int i=0; i<events_list.size(); i++) |
|
1600 { |
|
1601 if(constants.contains(i+1)) |
|
1602 continue; |
|
1603 |
|
1604 cell = row.createCell(j++); |
|
1605 cell.setCellStyle(styles.get("cell_normal")); |
|
1606 |
|
1607 WindowGroupEventData eventSet = events_list.get(i); |
|
1608 |
|
1609 if(eventSet == null){ |
|
1610 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
1611 } |
|
1612 else |
|
1613 { |
|
1614 StringBuffer tmp = new StringBuffer(); |
|
1615 |
|
1616 if(eventSet.getEvent_0_count() > 0) |
|
1617 tmp.append(" NoEvent(" + eventSet.getEvent_0_count() + ")"); |
|
1618 if(eventSet.getEvent_1_count() > 0) |
|
1619 tmp.append(" NameChanged(" + eventSet.getEvent_1_count() + ")"); |
|
1620 if(eventSet.getEvent_2_count() > 0) |
|
1621 tmp.append(" FocusGained(" + eventSet.getEvent_2_count() + ")"); |
|
1622 if(eventSet.getEvent_3_count() > 0) |
|
1623 tmp.append(" FocusLost(" + eventSet.getEvent_3_count() + ")"); |
|
1624 |
|
1625 cell.setCellValue(new HSSFRichTextString(tmp.toString())); |
|
1626 } |
|
1627 |
|
1628 } |
|
1629 } |
|
1630 |
|
1631 for(int i=0; i <= logData.getNumberOfCycles(); i++) |
|
1632 sheet.autoSizeColumn((short)i); |
|
1633 |
|
1634 cell = description.createCell(0); |
|
1635 cell.setCellValue(new HSSFRichTextString("Specifies the type and number of events for each window group, in each cycle.")); |
|
1636 } |
|
1637 } |
|
1638 /** |
|
1639 * create set of cell styles |
|
1640 */ |
|
1641 private Map<String, HSSFCellStyle> createStyles(HSSFWorkbook wb){ |
|
1642 Map<String, HSSFCellStyle> styles = new HashMap<String, HSSFCellStyle>(); |
|
1643 |
|
1644 HSSFCellStyle style; |
|
1645 HSSFFont headerFont = wb.createFont(); |
|
1646 headerFont.setColor(HSSFColor.WHITE.index); |
|
1647 headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL); |
|
1648 headerFont.setFontHeightInPoints((short)18); |
|
1649 style = createBorderedStyle(wb); |
|
1650 style.setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1651 style.setFillForegroundColor(HSSFColor.BLUE.index); |
|
1652 style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); |
|
1653 style.setFont(headerFont); |
|
1654 styles.put("header", style); |
|
1655 |
|
1656 HSSFFont font1 = wb.createFont(); |
|
1657 font1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); |
|
1658 font1.setFontHeightInPoints((short)12); |
|
1659 font1.setFontName(HSSFFont.FONT_ARIAL); |
|
1660 font1.setColor(HSSFColor.WHITE.index); |
|
1661 style = createBorderedStyle(wb); |
|
1662 style.setAlignment(HSSFCellStyle.ALIGN_CENTER); |
|
1663 style.setFillForegroundColor(HSSFColor.BLUE.index); |
|
1664 style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); |
|
1665 style.setFont(font1); |
|
1666 style.setWrapText(true); |
|
1667 styles.put("header2", style); |
|
1668 |
|
1669 style = createBorderedStyle(wb); |
|
1670 style.setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1671 style.setFillForegroundColor(HSSFColor.BLUE.index); |
|
1672 style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); |
|
1673 style.setFont(font1); |
|
1674 style.setWrapText(true); |
|
1675 styles.put("header1", style); |
|
1676 |
|
1677 HSSFFont font3 = wb.createFont(); |
|
1678 font3.setColor(HSSFColor.BLACK.index); |
|
1679 font3.setFontHeightInPoints((short)10); |
|
1680 font3.setFontName(HSSFFont.FONT_ARIAL); |
|
1681 font3.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); |
|
1682 style = createBorderedStyle(wb); |
|
1683 style.setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1684 style.setFont(font3); |
|
1685 styles.put("cell_bold", style); |
|
1686 |
|
1687 HSSFFont font5 = wb.createFont(); |
|
1688 font5.setColor(HSSFColor.BLACK.index); |
|
1689 font5.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL); |
|
1690 style = createBorderedStyle(wb); |
|
1691 style.setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1692 style.setFont(font5); |
|
1693 styles.put("cell_normal", style); |
|
1694 |
|
1695 HSSFFont font4 = wb.createFont(); |
|
1696 font4.setFontHeightInPoints((short)10); |
|
1697 font4.setColor(HSSFColor.WHITE.index); |
|
1698 style = createBorderedStyle(wb); |
|
1699 style.setFillForegroundColor(HSSFColor.BLUE.index); |
|
1700 style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); |
|
1701 style.setFont(font4); |
|
1702 styles.put("cell_blue_font_white", style); |
|
1703 |
|
1704 style = createBorderedStyle(wb); |
|
1705 style.setAlignment(HSSFCellStyle.ALIGN_RIGHT); |
|
1706 styles.put("cell_number", style); |
|
1707 |
|
1708 HSSFFont blue_font = wb.createFont(); |
|
1709 blue_font.setFontHeightInPoints((short)10); |
|
1710 blue_font.setColor(HSSFColor.BLUE.index); |
|
1711 style = createBorderedStyle(wb); |
|
1712 style.setAlignment(HSSFCellStyle.ALIGN_RIGHT); |
|
1713 style.setFont(blue_font); |
|
1714 styles.put("blue_font", style); |
|
1715 |
|
1716 return styles; |
|
1717 } |
|
1718 |
|
1719 private HSSFCellStyle createBorderedStyle(HSSFWorkbook wb){ |
|
1720 HSSFCellStyle style = wb.createCellStyle(); |
|
1721 style.setBorderRight(HSSFCellStyle.BORDER_THIN); |
|
1722 style.setRightBorderColor(HSSFColor.BLACK.index); |
|
1723 style.setBorderBottom(HSSFCellStyle.BORDER_THIN); |
|
1724 style.setBottomBorderColor(HSSFColor.BLACK.index); |
|
1725 style.setBorderLeft(HSSFCellStyle.BORDER_THIN); |
|
1726 style.setLeftBorderColor(HSSFColor.BLACK.index); |
|
1727 style.setBorderTop(HSSFCellStyle.BORDER_THIN); |
|
1728 style.setTopBorderColor(HSSFColor.BLACK.index); |
|
1729 return style; |
|
1730 } |
|
1731 |
|
1732 /** |
|
1733 * This method adds cells with values of time intervals between |
|
1734 * consecutive cycles to given row. |
|
1735 * @param row |
|
1736 */ |
|
1737 private void addCycleIntervals(HSSFRow row) |
|
1738 { |
|
1739 HSSFCell cell = null; |
|
1740 |
|
1741 SWMTLogReaderUtils utils = new SWMTLogReaderUtils(); |
|
1742 |
|
1743 cell = row.createCell(1); |
|
1744 cell.setCellStyle(styles.get("header2")); |
|
1745 cell.setCellValue(0); |
|
1746 |
|
1747 if(logData == null) |
|
1748 return; |
|
1749 |
|
1750 long prevDuration = 0; |
|
1751 |
|
1752 int i; |
|
1753 String currentTime = ""; |
|
1754 String prevTime = ""; |
|
1755 int j=1; |
|
1756 int filesSkipped = 1; |
|
1757 |
|
1758 CycleData [] cycles = logData.getLogData(); |
|
1759 |
|
1760 for(i=1; i<logData.getNumberOfCycles();i++) |
|
1761 { |
|
1762 if(constants.contains(i+1)) |
|
1763 { |
|
1764 filesSkipped++ ; |
|
1765 continue; |
|
1766 } |
|
1767 j++; |
|
1768 currentTime = cycles[i].getTime(); |
|
1769 //if(constants.contains(i-1)) |
|
1770 // prevTime = logData.get(i-2).getTime(); |
|
1771 //else |
|
1772 // prevTime = logData.get(i-1).getTime(); |
|
1773 prevTime = cycles[i-filesSkipped].getTime(); |
|
1774 |
|
1775 long timeDiff = utils.getDurationInSeconds(prevTime, currentTime); |
|
1776 cell = row.createCell(j); |
|
1777 cell.setCellStyle(styles.get("header2")); |
|
1778 cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); |
|
1779 |
|
1780 if(timeDiff < 0) |
|
1781 { |
|
1782 cell.setCellValue(new HSSFRichTextString("Cycle " + (i+1))); |
|
1783 return; |
|
1784 } |
|
1785 else |
|
1786 { |
|
1787 timeDiff += prevDuration; |
|
1788 prevDuration = timeDiff; |
|
1789 |
|
1790 cell.setCellValue(timeDiff); |
|
1791 } |
|
1792 filesSkipped = 1; |
|
1793 } |
|
1794 |
|
1795 } |
|
1796 |
|
1797 private void createOverviewFields(HSSFRow row) |
|
1798 { |
|
1799 HSSFCell cell = row.createCell(0); |
|
1800 cell.setCellStyle(styles.get("header1")); |
|
1801 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1802 cell.setCellValue(new HSSFRichTextString("Threads")); |
|
1803 |
|
1804 cell = row.createCell(1); |
|
1805 cell.setCellStyle(styles.get("header1")); |
|
1806 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1807 cell.setCellValue(new HSSFRichTextString("Status")); |
|
1808 |
|
1809 cell = row.createCell(2); |
|
1810 cell.setCellStyle(styles.get("header1")); |
|
1811 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1812 cell.setCellValue(new HSSFRichTextString("Max Heap Size")); |
|
1813 |
|
1814 cell = row.createCell(3); |
|
1815 cell.setCellStyle(styles.get("header1")); |
|
1816 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1817 cell.setCellValue(new HSSFRichTextString("Change in Heap \n size (in Bytes)")); |
|
1818 |
|
1819 cell = row.createCell(4); |
|
1820 cell.setCellStyle(styles.get("header1")); |
|
1821 cell.setCellValue(new HSSFRichTextString("Change in Heap Allocated \n space (in Bytes) ")); |
|
1822 |
|
1823 cell = row.createCell(5); |
|
1824 cell.setCellStyle(styles.get("header1")); |
|
1825 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1826 cell.setCellValue(new HSSFRichTextString("Change in Heap \n Free space (in Bytes)")); |
|
1827 |
|
1828 cell = row.createCell(6); |
|
1829 cell.setCellStyle(styles.get("header1")); |
|
1830 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1831 cell.setCellValue(new HSSFRichTextString("Change in Allocated \n Cell Count")); |
|
1832 |
|
1833 cell = row.createCell(7); |
|
1834 cell.setCellStyle(styles.get("header1")); |
|
1835 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1836 cell.setCellValue(new HSSFRichTextString("Change in Free \n Cell Count")); |
|
1837 |
|
1838 cell = row.createCell(8); |
|
1839 cell.setCellStyle(styles.get("header1")); |
|
1840 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1841 cell.setCellValue(new HSSFRichTextString("Change in Slack \n space size (in Bytes) ")); |
|
1842 |
|
1843 cell = row.createCell(9); |
|
1844 cell.setCellStyle(styles.get("header1")); |
|
1845 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1846 cell.setCellValue(new HSSFRichTextString("Stack size")); |
|
1847 |
|
1848 cell = row.createCell(10); |
|
1849 cell.setCellStyle(styles.get("header1")); |
|
1850 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1851 cell.setCellValue(new HSSFRichTextString("No. of Files \n opened")); |
|
1852 |
|
1853 cell = row.createCell(11); |
|
1854 cell.setCellStyle(styles.get("header1")); |
|
1855 cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_LEFT); |
|
1856 cell.setCellValue(new HSSFRichTextString("No. of \n P&S Handles")); |
|
1857 |
|
1858 } |
|
1859 |
|
1860 private void createDataInOverView(HSSFSheet sheet, int rowNo) |
|
1861 { |
|
1862 SWMTLogReaderUtils utils = new SWMTLogReaderUtils(); |
|
1863 |
|
1864 ArrayList<String> allThreads = utils.getAllThreadNames(logData); |
|
1865 Collections.sort(allThreads); |
|
1866 |
|
1867 long [] maxHeapSizes = new long[allThreads.size()]; |
|
1868 long [] heapSizes = new long[allThreads.size()]; |
|
1869 long [] freeCells = new long[allThreads.size()]; |
|
1870 long [] allocCells = new long[allThreads.size()]; |
|
1871 long [] freeSpace = new long[allThreads.size()]; |
|
1872 long [] allocSpace = new long[allThreads.size()]; |
|
1873 long [] slackSpace = new long[allThreads.size()]; |
|
1874 long [] totalFiles = new long[allThreads.size()]; |
|
1875 long [] totalHandles = new long[allThreads.size()]; |
|
1876 long [] totalStacks = new long[allThreads.size()]; |
|
1877 |
|
1878 int i =0; |
|
1879 |
|
1880 for(String thName:allThreads) |
|
1881 { |
|
1882 if(thName.startsWith("MemSpy") && thName.endsWith("::MemSpy")) |
|
1883 continue; |
|
1884 |
|
1885 HSSFRow row = sheet.createRow(rowNo); |
|
1886 HSSFCell cell = row.createCell(0); |
|
1887 |
|
1888 cell.setCellStyle(styles.get("cell_normal")); |
|
1889 cell.setCellValue(new HSSFRichTextString(thName)); |
|
1890 |
|
1891 cell = row.createCell(1); |
|
1892 cell.setCellStyle(styles.get("cell_normal")); |
|
1893 |
|
1894 if(logData.getNumberOfCycles() == 1) |
|
1895 { |
|
1896 cell.setCellValue(new HSSFRichTextString("Alive")); |
|
1897 } |
|
1898 else |
|
1899 { |
|
1900 int status = utils.getThreadStatusFromAllCycles(thName, logData); |
|
1901 |
|
1902 if(status == 0) |
|
1903 cell.setCellValue(new HSSFRichTextString("Dead")); |
|
1904 else if(status == 1 || status == 2) |
|
1905 cell.setCellValue(new HSSFRichTextString("Alive")); |
|
1906 else |
|
1907 cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE)); |
|
1908 } |
|
1909 |
|
1910 ThreadData threadDelta = deltaData.get(thName.toLowerCase()); |
|
1911 |
|
1912 cell = row.createCell(2); |
|
1913 cell.setCellStyle(styles.get("cell_number")); |
|
1914 cell.setCellValue(threadDelta.getMaxHeapSize()); |
|
1915 |
|
1916 maxHeapSizes[i] = threadDelta.getMaxHeapSize(); |
|
1917 /*ArrayList<String> heapThreads = utils.getAllHeapThreads(logData); |
|
1918 long delta = 0; |
|
1919 long lastValue = 0; |
|
1920 |
|
1921 ArrayList<ThreadData> heapData = utils.getHeapDataFromAllCycles(thName, logData); |
|
1922 |
|
1923 if(utils.getHeapStatusFromAllCycles(thName, logData) == 0) |
|
1924 { |
|
1925 //Display zeros for all heap fields |
|
1926 maxHeapSize = 0; |
|
1927 delta = 0; |
|
1928 } |
|
1929 else{ |
|
1930 lastValue = heapData.get(logData.size()-1).getHeapChunkSize(); |
|
1931 maxHeapSize = heapData.get(logData.size()-1).getMaxHeapSize(); |
|
1932 |
|
1933 long firstValue = 0; |
|
1934 |
|
1935 for(int i=heapData.size()-2; i>=0; i--) |
|
1936 { |
|
1937 ThreadData data = heapData.get(i); |
|
1938 if(data.getStatus() != CycleData.Deleted){ |
|
1939 firstValue = data.getHeapChunkSize(); |
|
1940 } |
|
1941 else |
|
1942 break; |
|
1943 } |
|
1944 |
|
1945 if(firstValue != -1) |
|
1946 delta = lastValue - firstValue; |
|
1947 } */ |
|
1948 |
|
1949 //cell.setCellValue(maxHeapSize); |
|
1950 |
|
1951 cell = row.createCell(3); |
|
1952 cell.setCellStyle(styles.get("cell_number")); |
|
1953 cell.setCellValue(threadDelta.getHeapChunkSize()); |
|
1954 heapSizes[i] = threadDelta.getHeapChunkSize(); |
|
1955 |
|
1956 cell = row.createCell(4); |
|
1957 cell.setCellStyle(styles.get("cell_number")); |
|
1958 cell.setCellValue(threadDelta.getHeapAllocatedSpace()); |
|
1959 allocSpace[i] = threadDelta.getHeapAllocatedSpace(); |
|
1960 |
|
1961 cell = row.createCell(5); |
|
1962 cell.setCellStyle(styles.get("cell_number")); |
|
1963 cell.setCellValue(threadDelta.getHeapFreeSpace()); |
|
1964 freeSpace[i] = threadDelta.getHeapFreeSpace(); |
|
1965 |
|
1966 cell = row.createCell(6); |
|
1967 cell.setCellStyle(styles.get("cell_number")); |
|
1968 cell.setCellValue(threadDelta.getAllocatedCells()); |
|
1969 allocCells[i] = threadDelta.getAllocatedCells(); |
|
1970 |
|
1971 cell = row.createCell(7); |
|
1972 cell.setCellStyle(styles.get("cell_number")); |
|
1973 cell.setCellValue(threadDelta.getFreeCells()); |
|
1974 freeCells[i] = threadDelta.getFreeCells(); |
|
1975 |
|
1976 cell = row.createCell(8); |
|
1977 cell.setCellStyle(styles.get("cell_number")); |
|
1978 cell.setCellValue(threadDelta.getFreeSlackSize()); |
|
1979 slackSpace[i] = threadDelta.getFreeSlackSize(); |
|
1980 |
|
1981 cell = row.createCell(9); |
|
1982 cell.setCellStyle(styles.get("cell_number")); |
|
1983 cell.setCellValue(threadDelta.getStackSize()); |
|
1984 totalStacks[i] = threadDelta.getStackSize(); |
|
1985 |
|
1986 cell = row.createCell(10); |
|
1987 cell.setCellStyle(styles.get("cell_number")); |
|
1988 cell.setCellValue(threadDelta.getOpenFiles()); |
|
1989 totalFiles[i] = threadDelta.getOpenFiles(); |
|
1990 |
|
1991 cell = row.createCell(11); |
|
1992 cell.setCellStyle(styles.get("cell_number")); |
|
1993 cell.setCellValue(threadDelta.getPsHandles()); |
|
1994 totalHandles[i] = threadDelta.getPsHandles(); |
|
1995 |
|
1996 i++; |
|
1997 |
|
1998 rowNo++; |
|
1999 } |
|
2000 |
|
2001 if(allThreads.size() > 0) |
|
2002 { |
|
2003 |
|
2004 HSSFRow totalRow = sheet.createRow(rowNo); |
|
2005 |
|
2006 long totalMaxHeapSize = utils.calculateAndGetTotal(maxHeapSizes); |
|
2007 long totalStackSize = utils.calculateAndGetTotal(totalStacks); |
|
2008 totalHeapSizeChange = utils.calculateAndGetTotal(heapSizes); |
|
2009 totalFreeCellChange = utils.calculateAndGetTotal(freeCells); |
|
2010 totalAllocCellChange = utils.calculateAndGetTotal(allocCells); |
|
2011 totalFreeSpaceChange = utils.calculateAndGetTotal(freeSpace); |
|
2012 totalAllocSpaceChange = utils.calculateAndGetTotal(allocSpace); |
|
2013 totalSlackSpaceChange = utils.calculateAndGetTotal(slackSpace); |
|
2014 totalFilesChange = utils.calculateAndGetTotal(totalFiles); |
|
2015 totalHandlesChange = utils.calculateAndGetTotal(totalHandles); |
|
2016 |
|
2017 HSSFCell cell = totalRow.createCell(2); |
|
2018 cell.setCellStyle(styles.get("cell_blue_font_white")); |
|
2019 cell.setCellValue(totalMaxHeapSize); |
|
2020 |
|
2021 cell = totalRow.createCell(3); |
|
2022 cell.setCellStyle(styles.get("cell_blue_font_white")); |
|
2023 cell.setCellValue(totalHeapSizeChange); |
|
2024 |
|
2025 cell = totalRow.createCell(4); |
|
2026 cell.setCellStyle(styles.get("cell_blue_font_white")); |
|
2027 cell.setCellValue(totalAllocSpaceChange); |
|
2028 |
|
2029 cell = totalRow.createCell(5); |
|
2030 cell.setCellStyle(styles.get("cell_blue_font_white")); |
|
2031 cell.setCellValue(totalFreeSpaceChange); |
|
2032 |
|
2033 cell = totalRow.createCell(6); |
|
2034 cell.setCellStyle(styles.get("cell_blue_font_white")); |
|
2035 cell.setCellValue(totalAllocCellChange); |
|
2036 |
|
2037 cell = totalRow.createCell(7); |
|
2038 cell.setCellStyle(styles.get("cell_blue_font_white")); |
|
2039 cell.setCellValue(totalFreeCellChange); |
|
2040 |
|
2041 cell = totalRow.createCell(8); |
|
2042 cell.setCellStyle(styles.get("cell_blue_font_white")); |
|
2043 cell.setCellValue(totalSlackSpaceChange); |
|
2044 |
|
2045 cell = totalRow.createCell(9); |
|
2046 cell.setCellStyle(styles.get("cell_blue_font_white")); |
|
2047 cell.setCellValue(totalStackSize); |
|
2048 |
|
2049 cell = totalRow.createCell(10); |
|
2050 cell.setCellStyle(styles.get("cell_blue_font_white")); |
|
2051 cell.setCellValue(totalFilesChange); |
|
2052 |
|
2053 cell = totalRow.createCell(11); |
|
2054 cell.setCellStyle(styles.get("cell_blue_font_white")); |
|
2055 cell.setCellValue(totalHandlesChange); |
|
2056 } |
|
2057 |
|
2058 } |
|
2059 private void readHeapDataFromAllCycles(Map<String, ArrayList<ThreadData>> map, ParsedData logData) |
|
2060 { |
|
2061 SWMTLogReaderUtils utils = new SWMTLogReaderUtils(); |
|
2062 //heapThreads = utils.getAllHeapThreads(logData); |
|
2063 |
|
2064 ArrayList<String> allThreads = utils.getAllThreadNames(logData); |
|
2065 for(String heap:allThreads) |
|
2066 { |
|
2067 //ignoring the data related to MemSpy threads |
|
2068 if(heap.startsWith("MemSpy") && heap.endsWith("::MemSpy")) |
|
2069 continue; |
|
2070 |
|
2071 ArrayList<ThreadData> heapData = utils.getHeapDataFromAllCycles(heap, logData); |
|
2072 |
|
2073 map.put(heap.toLowerCase(), heapData); |
|
2074 } |
|
2075 } |
|
2076 |
|
2077 private void readGlobalDataFromAllCycles(Map<String, ArrayList<GlobalDataChunks>> map, ParsedData logData) |
|
2078 { |
|
2079 SWMTLogReaderUtils utils = new SWMTLogReaderUtils(); |
|
2080 glodChunks = utils.getAllGlobalChunkNames(logData); |
|
2081 |
|
2082 Collections.sort(glodChunks); |
|
2083 for(String glod:glodChunks) |
|
2084 { |
|
2085 ArrayList<GlobalDataChunks> globData = utils.getGLOBDataFromAllCycles(glod, logData); |
|
2086 map.put(glod, globData); |
|
2087 } |
|
2088 } |
|
2089 |
|
2090 private void readChunkDataFromAllCycles(Map<String, ArrayList<ChunksData>> map, ParsedData logData) |
|
2091 { |
|
2092 SWMTLogReaderUtils utils = new SWMTLogReaderUtils(); |
|
2093 nonHeapChunks = utils.getAllNonHeapChunkNames(logData); |
|
2094 |
|
2095 Collections.sort(nonHeapChunks); |
|
2096 for(String chunk:nonHeapChunks) |
|
2097 { |
|
2098 ArrayList<ChunksData> globData = utils.getChunkDataFromAllCycles(chunk, logData); |
|
2099 map.put(chunk, globData); |
|
2100 } |
|
2101 } |
|
2102 |
|
2103 private void getFieldDifferencesForAllThreads(Map<String, ThreadData> map, ParsedData logData) |
|
2104 { |
|
2105 SWMTLogReaderUtils utils = new SWMTLogReaderUtils(); |
|
2106 |
|
2107 ArrayList<String> allThreads = utils.getAllThreadNames(logData); |
|
2108 |
|
2109 for(String s:allThreads) |
|
2110 { |
|
2111 //ignoring the data related to MemSpy threads |
|
2112 if(s.startsWith("MemSpy") && s.endsWith("::MemSpy")) |
|
2113 continue; |
|
2114 |
|
2115 ThreadData delta = utils.getChangeinHeapData(s, heapData.get(s.toLowerCase()), logData); |
|
2116 |
|
2117 map.put(s.toLowerCase(), delta); |
|
2118 } |
|
2119 } |
|
2120 |
|
2121 private void getFieldDifferencesForAllGlodChunks(Map<String, String> map, ParsedData logData) |
|
2122 { |
|
2123 SWMTLogReaderUtils utils = new SWMTLogReaderUtils(); |
|
2124 |
|
2125 ArrayList<String> allGlodChunks = utils.getAllGlobalChunkNames(logData); |
|
2126 |
|
2127 for(String s:allGlodChunks) |
|
2128 { |
|
2129 long delta = utils.getChangeinGlodChunksData(s, logData); |
|
2130 |
|
2131 map.put(s, delta+""); |
|
2132 } |
|
2133 } |
|
2134 |
|
2135 private void getFieldDifferencesForAllChunks(Map<String, String> map, ParsedData logData) |
|
2136 { |
|
2137 SWMTLogReaderUtils utils = new SWMTLogReaderUtils(); |
|
2138 |
|
2139 ArrayList<String> allChunks = utils.getAllNonHeapChunkNames(logData); |
|
2140 |
|
2141 for(String s:allChunks) |
|
2142 { |
|
2143 long delta = utils.getChangeinChunksData(s, logData); |
|
2144 |
|
2145 map.put(s, delta+""); |
|
2146 } |
|
2147 } |
|
2148 } |