Skip to content
Snippets Groups Projects

Feature #645 clarify multicast delivery

Files

@@ -3,25 +3,30 @@ import sys
@@ -3,25 +3,30 @@ import sys
import re
import re
# Script that translates multicast analysis into a plot of average and minimum delivery rate over time.
# Script that translates multicast analysis into a plot of average and minimum delivery rate over time.
 
# The rates are calculated for both messages that exist at that time and all messages that ever existed
# Takes as arguments
# Takes as arguments
# (1) a multicast analysis file
# (1) a multicast analysis file
# (2) path to save the graphic to.
# (2) path to save the graphic to.
#
#
# The multicast analysis file should have a format like:
# The multicast analysis file should have a format like:
#
#
# #timeAfterMessageCreation MinRatio AvgRatio
# #timeAfterMessageCreation MinRatio AvgRatio MinRatioForAll AvgRatioForAll
# 300 0.0 0.00444165511837884
# 300 0.0 0.00444165511837884 0.0 0.004223002342392
# 600 0.0 0.0164942207497068
# 600 0.0 0.0164942207497068 0.0 0.01223002342392
# 900 0.0 0.0340330430435976
# 900 0.0 0.0340330430435976 0.0 0.024223002342392
# Draws two functions over the same x values.
# Draws two functions over the same x values.
# Labels are selected as appropiate for multicast analysis.
# Labels are selected as appropiate for multicast analysis.
def drawPlots(x, y_minimum, y_average):
def drawPlots(x, y_minimum, y_average, y_minForAll, y_avgForAll):
plt.title('Multicast delivery rates')
plt.title('Multicast delivery rates')
plt.xlabel('Minutes since message creation')
plt.xlabel('Minutes since message creation')
plt.ylabel('Delivery rate')
plt.ylabel('Delivery rate')
plt.plot(x, y_minimum, '.-', label='Minimum')
plt.plot(x, y_minimum, '.-', label='Minimum for existent messages')
plt.plot(x, y_average, '.-', label='Average')
plt.plot(x, y_average, '.-', label='Average for existent messages')
 
#Currently not plotted as both minima are constantly zero and if the ever get higher it will be more noticably in
 
#the minimum delivery ratio for existent messages, two overlaying graphs make viewers search for the 'missing' one
 
#plt.plot(x, y_minForAll, '.-', label='Minimum for all messages ever created')
 
plt.plot(x, y_avgForAll, '.-', label='Average for all messages ever created')
plt.legend(loc='upper left')
plt.legend(loc='upper left')
plt.grid(True)
plt.grid(True)
@@ -36,17 +41,21 @@ def main(analysisFileName, graphicFileName):
@@ -36,17 +41,21 @@ def main(analysisFileName, graphicFileName):
# Interpret lines to find minimum and average delivery rates over time
# Interpret lines to find minimum and average delivery rates over time
timePoints = []
timePoints = []
minimum = []
minimum = []
 
minimumForAll = []
average = []
average = []
 
averageForAll = []
for line in analysis:
for line in analysis:
match = re.match("(\d+)\s+(\d+.\d+)\s+(\d+(?:.\d*)?)", line)
match = re.match("(\d+)\s+(\d+.\d+)\s+(\d+(?:.\d*)?)\s+(\d+(?:.\d*)?)\s+(\d+(?:.\d*)?)", line)
if match is None:
if match is None:
continue
continue
timePoints.append(float(match.group(1)) / 60)
timePoints.append(float(match.group(1)) / 60)
minimum.append(float(match.group(2)))
minimum.append(float(match.group(2)))
average.append(float(match.group(3)))
average.append(float(match.group(3)))
 
minimumForAll.append(float(match.group(4)))
 
averageForAll.append(float(match.group(5)))
# Draw plots.
# Draw plots.
drawPlots(timePoints, minimum, average)
drawPlots(timePoints, minimum, average, minimumForAll, averageForAll)
# Save to file
# Save to file
plt.savefig(graphicFileName)
plt.savefig(graphicFileName)
Loading