From c889a4ef4558f496cbd5a5103bd23464073cb6a3 Mon Sep 17 00:00:00 2001 From: "selva.andre" Date: Fri, 31 Aug 2012 19:45:36 +0200 Subject: [PATCH] Added groovy scripts to create a report for metrics measurments --- tools_scripts/benchmarkReportGenerator.groovy | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tools_scripts/benchmarkReportGenerator.groovy diff --git a/tools_scripts/benchmarkReportGenerator.groovy b/tools_scripts/benchmarkReportGenerator.groovy new file mode 100644 index 00000000..22926ca1 --- /dev/null +++ b/tools_scripts/benchmarkReportGenerator.groovy @@ -0,0 +1,65 @@ +/** + * Script used to reconstruct statistics + */ + +Map populateWithTimings(reportFile, timingsMap) { + reportFile.eachLine {String line -> + if (line.startsWith("msg ID")) { + return + } + def tab = line.split(",") + int msgId = tab[0].trim() as int + long time = tab[1].trim() as long + + //TODO notify an alert in case of collisions + timingsMap[msgId] = time + } + timingsMap +} + +Map calculateTransportTime(prodMap, consMap) { + Map transportMap = [:] + consMap.each {msgId, arrivalTime -> + long time = arrivalTime - prodMap[msgId] + transportMap[msgId] = time + } + transportMap +} + +Map consumerTimings = [:] +println "Load consumer receive timings" +def consumerReport = new File("/home/andrea/workspace/moquette/consumer_bechmark.txt"); +populateWithTimings(consumerReport, consumerTimings) + +println "consumer timings loaded ${consumerTimings.size()} records" + +Map producerTimings = [:] +def producerReport1 = new File("/home/andrea/workspace/moquette/producer_bechmark_Prod1.txt"); +def producerReport2 = new File("/home/andrea/workspace/moquette/producer_bechmark_Prod2.txt"); +populateWithTimings(producerReport1, producerTimings) +println "producer 1 timings loaded ${producerTimings.size()} records" + +populateWithTimings(producerReport2, producerTimings) +println "producer 2 timings loaded ${producerTimings.size()} records" + +Map report = calculateTransportTime(producerTimings, consumerTimings) +File reportFile = new File("/home/andrea/workspace/moquette/report.txt") + +def minTime = report.min {it.value}.value / (10 ** 6) +def maxTime = report.max {it.value}.value / (10 ** 6) +def totalTime = 0 + +report = report.sort() + +report.each {msgID, time -> + totalTime += time + reportFile << "$msgID, $time\n" +} + +def meanTime = (totalTime / report.size() ) / (10 ** 6) +reportFile << "min $minTime \n max $maxTime \n mean $meanTime \n" + +println "created report file $reportFile" +//reportFile.close() + +