/** * Merge this ExecutionStatistics with all the statistics created within the child threads. All the child threads had to be created using Windup-specific * ThreadFactory in order to contain a reference to the parent thread. */ public void merge() { Thread currentThread = Thread.currentThread(); if(!stats.get(currentThread).equals(this) || currentThread instanceof WindupChildThread) { throw new IllegalArgumentException("Trying to merge executionstatistics from a " + "different thread that is not registered as main thread of application run"); } for (Thread thread : stats.keySet()) { if(thread instanceof WindupChildThread && ((WindupChildThread) thread).getParentThread().equals(currentThread)) { merge(stats.get(thread)); } } }
/** * Merge this ExecutionStatistics with all the statistics created within the child threads. All the child threads had to be created using Windup-specific * ThreadFactory in order to contain a reference to the parent thread. */ public void merge() { Thread currentThread = Thread.currentThread(); if(!stats.get(currentThread).equals(this) || currentThread instanceof WindupChildThread) { throw new IllegalArgumentException("Trying to merge executionstatistics from a " + "different thread that is not registered as main thread of application run"); } for (Thread thread : stats.keySet()) { if(thread instanceof WindupChildThread && ((WindupChildThread) thread).getParentThread().equals(currentThread)) { merge(stats.get(thread)); } } }
/** * Serializes the timing data to a "~" delimited file at outputPath. */ public void serializeTimingData(Path outputPath) { //merge subThreads instances into the main instance merge(); try (FileWriter fw = new FileWriter(outputPath.toFile())) { fw.write("Number Of Executions, Total Milliseconds, Milliseconds per execution, Type\n"); for (Map.Entry<String, TimingData> timing : executionInfo.entrySet()) { TimingData data = timing.getValue(); long totalMillis = (data.totalNanos / 1000000); double millisPerExecution = (double) totalMillis / (double) data.numberOfExecutions; fw.write(String.format("%6d, %6d, %8.2f, %s\n", data.numberOfExecutions, totalMillis, millisPerExecution, StringEscapeUtils.escapeCsv(timing.getKey()) )); } } catch (Exception e) { e.printStackTrace(); } }
/** * Serializes the timing data to a "~" delimited file at outputPath. */ public void serializeTimingData(Path outputPath) { //merge subThreads instances into the main instance merge(); try (FileWriter fw = new FileWriter(outputPath.toFile())) { fw.write("Number Of Executions, Total Milliseconds, Milliseconds per execution, Type\n"); for (Map.Entry<String, TimingData> timing : executionInfo.entrySet()) { TimingData data = timing.getValue(); long totalMillis = (data.totalNanos / 1000000); double millisPerExecution = (double) totalMillis / (double) data.numberOfExecutions; fw.write(String.format("%6d, %6d, %8.2f, %s\n", data.numberOfExecutions, totalMillis, millisPerExecution, StringEscapeUtils.escapeCsv(timing.getKey()) )); } } catch (Exception e) { e.printStackTrace(); } }