Skip to content

Commit

Permalink
Merge pull request #97 from intellistream/Revision_1010
Browse files Browse the repository at this point in the history
Revision 1010
  • Loading branch information
TONYSKYZENG authored Oct 11, 2023
2 parents dce563a + 0e9e0e3 commit a01d169
Show file tree
Hide file tree
Showing 100 changed files with 2,418 additions and 223 deletions.
2 changes: 1 addition & 1 deletion commit.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

BRANCH=Figure_withCdf
BRANCH=Revision_1010
git init
git checkout -b $BRANCH
git add .
Expand Down
Binary file modified scripts/Revised1_tradeoff/__pycache__/OoOCommon.cpython-310.pyc
Binary file not shown.
Binary file modified scripts/Revised1_tradeoff/__pycache__/accuBar.cpython-310.pyc
Binary file not shown.
Binary file modified scripts/Revised1_tradeoff/__pycache__/autoParase.cpython-310.pyc
Binary file not shown.
Binary file modified scripts/Revised1_tradeoff/__pycache__/groupBar.cpython-310.pyc
Binary file not shown.
Binary file modified scripts/Revised1_tradeoff/__pycache__/groupBar2.cpython-310.pyc
Binary file not shown.
Binary file modified scripts/Revised1_tradeoff/__pycache__/groupLine.cpython-310.pyc
Binary file not shown.
8 changes: 5 additions & 3 deletions scripts/Revised1_tradeoff/drawTogether.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ def main():

figPath = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/figures/"
configTemplate = exeSpace + "config.csv"
periodVec = [7, 8, 9, 10, 11, 12, 14]
periodVec = [7, 8, 9, 10, 11, 12, 14,16]
periodVecDisp = np.array(periodVec)
periodVecDisp = periodVecDisp
print(configTemplate)
methodTags = ["WMJ","KSJ", "PECJ", "Theoretical Best"]
methodTags = ["WMJ","KSJ", "PECJ", "Theoretical Best","User Demand"]
resultPaths = ["ks", "wa", "pecj_ks", "pec_ai"]
csvTemplates = ["config_yuanzhen.csv", "config_waterMark.csv", "config_pecj.csv", "config_pecjAI.csv"]
# run
Expand All @@ -138,7 +138,9 @@ def main():
lat95All, errAll, periodAll = compareMethod(exeSpace, commonBasePath, resultPaths, csvTemplates, periodVec, reRun)
lat95Temp = lat95All
lat95Temp[3] = lat95Temp[2]
groupLine.DrawFigureYnormal(lat95Temp, np.array(errAll)*100.0, methodTags, "95% latency (ms)", "Error (%)", 0, 1, figPath + "revised1_tradeoff",
errTemp = errAll
errTemp[3] = np.minimum( errTemp[3], errTemp[2])
groupLine.DrawFigureYnormal(lat95Temp, np.array(errTemp)*100.0, methodTags, "95% latency (ms)", "Error (%)", 0, 1, figPath + "revised1_tradeoff",
True)

if __name__ == "__main__":
Expand Down
137 changes: 51 additions & 86 deletions scripts/Revised1_tradeoff/groupLine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import matplotlib.patches as patches

OPT_FONT_NAME = 'Helvetica'
TICK_FONT_SIZE = 20
TICK_FONT_SIZE = 26
LABEL_FONT_SIZE = 20
LEGEND_FONT_SIZE = 20
LEGEND_FONT_SIZE = 24
LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE)
LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE)
TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE)
Expand Down Expand Up @@ -148,17 +148,20 @@ def DrawFigureYnormal(xvalues, yvalues, legend_labels, x_label, y_label, y_min,
linewidth = 2

FIGURE_LABEL = legend_labels

x_values = xvalues

x_values =xvalues
print(x_values[0])
y_values = yvalues


#FIGURE_LABEL.append('User demand')
lines = [None] * (len(FIGURE_LABEL))
for i in range(len(y_values)):
lines[i], = plt.plot(x_values[i], y_values[i], color=colors[i], \
linewidth=linewidth, marker=markers[i], \
markersize=9, linestyle=linestyles[i], \
label=FIGURE_LABEL[i])
lines[len(FIGURE_LABEL)-1], = plt.plot(x_values[0], y_values[0]+5, color='#ffffff', \
linewidth=0.001,
label=FIGURE_LABEL[len(FIGURE_LABEL)-1])

# lines = [None] * (len(FIGURE_LABEL))
# for i in range(len(y_values)):
Expand All @@ -167,110 +170,72 @@ def DrawFigureYnormal(xvalues, yvalues, legend_labels, x_label, y_label, y_min,
# markersize=MARKER_SIZE, label=FIGURE_LABEL[i], markeredgecolor='k')

# sometimes you may not want to draw legends.
#FIGURE_LABEL=FIGURE_LABEL.append('User Demand')
if allow_legend == True:
plt.legend(lines,
FIGURE_LABEL,
prop=LEGEND_FP,
fontsize=12,
loc='upper center',
ncol=4,
bbox_to_anchor=(0.5, 1.25), shadow=False,
ncol=1,
bbox_to_anchor=(0.78, 1.1),
columnspacing=0.1,
frameon=True, borderaxespad=0, handlelength=1.2,
shadow=True,frameon=True,edgecolor='black',borderaxespad=1,
handletextpad=0.1,
labelspacing=0.1)
# plt.xscale('log')
#plt.xscale('log')
# plt.yscale('log')
# plt.yscale('log')

# you may control the limits on your own.

plt.ylim(0, 100)
#plt.ylim(0, np.max(y_values)*1.1)

plt.grid(axis='y', color='gray', alpha=0.5, linewidth=0.5)
figure.yaxis.set_major_locator(LinearLocator(5))
plt.grid(axis='y', color='0.1', alpha=0.5, linewidth=2.0)
# figure.xaxis.set_major_locator(LogLocator(base=10))
plt.xticks(fontsize=TICK_FONT_SIZE)
plt.yticks(fontsize=TICK_FONT_SIZE)
figure.get_xaxis().set_tick_params(direction='in', pad=10)
figure.get_yaxis().set_tick_params(direction='in', pad=10)
rectangle = patches.Rectangle((6.0, 0.00), 2.5, 20, edgecolor='black', hatch='\\', fill=False)
figure.text(7.0, 21, "user demand", fontsize=TICK_FONT_SIZE, ha='center')
plt.xlabel(x_label, fontsize=TICK_FONT_SIZE)
plt.ylabel(y_label, fontsize=TICK_FONT_SIZE)
xmin=np.min(xvalues)*0.9
rectangle = patches.Rectangle((xmin, 0.00),8.5-xmin , 20, color = '0.85',alpha = 0.5 )
#figure.text((xmin+8.5)/2, 10, "user demand", fontsize=TICK_FONT_SIZE, ha='center')
figure.add_patch(rectangle)
plt.xlabel(x_label, fontsize=20)
plt.ylabel(y_label, fontsize=20)


rectangle = patches.Rectangle((10.2, 37),0.8 , 5, color = '0.85',alpha = 0.5, zorder=65535 )
#figure.text((xmin+8.5)/2, 10, "user demand", fontsize=TICK_FONT_SIZE, ha='center')
figure.add_patch(rectangle)
# the bound of latency
figure.annotate('', xy=(8.3, 22), xytext=(xmin*1.1,22),
arrowprops=dict(arrowstyle='<-', color='black', lw=1.5))
# Draw a rectangle to represent the bounded vertical line
rect1 = patches.Rectangle((8.3, 20), 0.01, 3, linewidth=1.5, edgecolor='red', facecolor='none')
figure.add_patch(rect1)
rect1 = patches.Rectangle((xmin*1.1, 20), 0.01, 3, linewidth=1.5, edgecolor='red', facecolor='none')
figure.add_patch(rect1)
figure.text((xmin+8.5)/2, 23,r"$\leq 8.5 ms$", fontsize=TICK_FONT_SIZE, ha='center')
figure.axvline(x=8.5, color='red', linestyle='-.', linewidth=0.8)
# the bound of error
figure.annotate('', xy=(8.6, 19), xytext=(8.6,3),
arrowprops=dict(arrowstyle='<-', color='black', lw=1.5))
# Draw a rectangle to represent the bounded vertical line

rect2 = patches.Rectangle((8.5, 19), 0.1, 0.01, linewidth=2, edgecolor='red', facecolor='none')
figure.add_patch(rect2)
rect2 = patches.Rectangle((8.5, 3), 0.1, 0.01, linewidth=2, edgecolor='red', facecolor='none')
figure.add_patch(rect2)
figure.axhline(y=20, color='red', linestyle='-.', linewidth=0.8)
figure.text(9.5, 10,r"$\leq 20\%$", fontsize=TICK_FONT_SIZE, ha='center')
# Add the rectangle to the plot


#figure.axvline(x=8.5, ymax=23,ymin=0,color='red', linestyle='--', linewidth=2)
size = fig.get_size_inches()
dpi = fig.get_dpi()

plt.savefig(filename + ".pdf", bbox_inches='tight')

# draw a line chart
def DrawFigureYnormalLat(xvalues, yvalues, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend):
# you may change the figure size on your own.
fig = plt.figure(figsize=(10, 4))
figure = fig.add_subplot(111)
markers = ['s', 'o', '^', 'v', '+', '*', ',', 'x', 'p', '1', '2', 'o']
linestyles = ['-.', '-.', 'dotted', 'dotted', 'dotted', 'dotted', 'dotted', ':', 'dashed', 'dotted', 'dotted', '-']
colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22',
'#17becf', '#1f77b4']
linewidth = 2

FIGURE_LABEL = legend_labels

x_values = xvalues
y_values = yvalues


lines = [None] * (len(FIGURE_LABEL))
for i in range(len(y_values)):
lines[i], = plt.plot(x_values[i], y_values[i], color=colors[i], \
linewidth=linewidth, marker=markers[i], \
markersize=9, linestyle=linestyles[i], \
label=FIGURE_LABEL[i])

# lines = [None] * (len(FIGURE_LABEL))
# for i in range(len(y_values)):
# lines[i], = figure.plot(x_values[i], y_values[i], color=LINE_COLORS[i], \
# linewidth=LINE_WIDTH, marker=MARKERS[i], \
# markersize=MARKER_SIZE, label=FIGURE_LABEL[i], markeredgecolor='k')

# sometimes you may not want to draw legends.
if allow_legend == True:
plt.legend(lines,
FIGURE_LABEL,
prop=LEGEND_FP,
fontsize=12,
loc='upper center',
ncol=4,
bbox_to_anchor=(0.5, 1.25), shadow=False,
columnspacing=0.1,
frameon=True, borderaxespad=0, handlelength=1.2,
handletextpad=0.1,
labelspacing=0.1)
# plt.xscale('log')
# plt.yscale('log')
# plt.yscale('log')

# you may control the limits on your own.

plt.ylim(0, 200)

plt.grid(axis='y', color='gray', alpha=0.5, linewidth=0.5)
figure.yaxis.set_major_locator(LinearLocator(5))
# figure.xaxis.set_major_locator(LogLocator(base=10))
plt.xticks(fontsize=TICK_FONT_SIZE)
figure.get_xaxis().set_tick_params(direction='in', pad=10)
figure.get_yaxis().set_tick_params(direction='in', pad=10)

plt.xlabel(x_label, fontsize=20)
plt.ylabel(y_label, fontsize=20)


size = fig.get_size_inches()
dpi = fig.get_dpi()

plt.savefig(filename + ".pdf", bbox_inches='tight')

# draw a line chart

Expand Down Expand Up @@ -305,7 +270,7 @@ def DrawFigureYnormalErr(xvalues, yvalues, legend_labels, x_label, y_label, y_mi
fontsize=12,
loc='upper center',
ncol=5,
bbox_to_anchor=(0.5, 1.25), shadow=False,
bbox_to_anchor=(0.5, 1.15), shadow=False,
columnspacing=0.1,
frameon=True, borderaxespad=0, handlelength=1.2,
handletextpad=0.1,
Expand Down
125 changes: 125 additions & 0 deletions scripts/Revision_StockQ3/OoOCommon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import csv
import numpy as np
import matplotlib.pyplot as plt
import itertools as it
import os

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pylab
from matplotlib.font_manager import FontProperties
from matplotlib.ticker import LogLocator, LinearLocator
import os
import pandas as pd
import sys
import matplotlib.ticker as mtick

OPT_FONT_NAME = 'Helvetica'
TICK_FONT_SIZE = 22
LABEL_FONT_SIZE = 28
LEGEND_FONT_SIZE = 30
LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE)
LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE)
TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE)

MARKERS = (['*', '|', 'v', "^", "", "h", "<", ">", "+", "d", "<", "|", "", "+", "_"])
# you may want to change the color map for different figures
COLOR_MAP = (
'#B03A2E', '#2874A6', '#239B56', '#7D3C98', '#FFFFFF', '#F1C40F', '#F5CBA7', '#82E0AA', '#AEB6BF', '#AA4499')
# you may want to change the patterns for different figures
PATTERNS = (["////", "o", "", "||", "-", "//", "\\", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", "*"])
LABEL_WEIGHT = 'bold'
LINE_COLORS = COLOR_MAP
LINE_WIDTH = 3.0
MARKER_SIZE = 15.0
MARKER_FREQUENCY = 1000


def editConfig(src, dest, key, value):
df = pd.read_csv(src, header=None)
rowIdx = 0
idxt = 0
for cell in df[0]:
# print(cell)
if (cell == key):
rowIdx = idxt
break
idxt = idxt + 1
df[1][rowIdx] = str(value)
df.to_csv(dest, index=False, header=False)


def readConfig(src, key):
df = pd.read_csv(src, header=None)
rowIdx = 0
idxt = 0
for cell in df[0]:
# print(cell)
if (cell == key):
rowIdx = idxt
break
idxt = idxt + 1
return df[1][rowIdx]


def draw2yLine(NAME, Com, R1, R2, l1, l2, m1, m2, fname):
fig, ax1 = plt.subplots(figsize=(10, 6.4))
lines = [None] * 2
# ax1.set_ylim(0, 1)
print(Com)
print(R1)
lines[0], = ax1.plot(Com, R1, color=LINE_COLORS[0], \
linewidth=LINE_WIDTH, marker=MARKERS[0], \
markersize=MARKER_SIZE
#
)

# #plt.show()
ax1.set_ylabel(m1, fontproperties=LABEL_FP)
ax1.set_xlabel(NAME, fontproperties=LABEL_FP)
# ax1.set_xticklabels(ax1.get_xticklabels()) # 设置共用的x轴
plt.xticks(rotation=0, size=TICK_FONT_SIZE)
plt.yticks(rotation=0, size=TICK_FONT_SIZE)
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
ax2 = ax1.twinx()

# ax2.set_ylabel('latency/us')
# ax2.set_ylim(0, 0.5)
lines[1], = ax2.plot(Com, R2, color=LINE_COLORS[1], \
linewidth=LINE_WIDTH, marker=MARKERS[1], \
markersize=MARKER_SIZE)

ax2.set_ylabel(m2, fontproperties=LABEL_FP)
# ax2.vlines(192000, min(R2)-1, max(R2)+1, colors = "GREEN", linestyles = "dashed",label='total L1 size')
# plt.grid(axis='y', color='gray')

# style = dict(size=10, color='black')
# ax2.hlines(tset, 0, x2_list[len(x2_list)-1]+width, colors = "r", linestyles = "dashed",label="tset")
# ax2.text(4, tset, "$T_{set}$="+str(tset)+"us", ha='right', **style)

# plt.xlabel('batch', fontproperties=LABEL_FP)

# plt.xscale('log')
# figure.xaxis.set_major_locator(LinearLocator(5))
ax1.yaxis.set_major_locator(LinearLocator(5))
ax2.yaxis.set_major_locator(LinearLocator(5))
ax1.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f'))
ax2.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f'))
ax1.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f'))
ax2.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f'))
plt.legend(lines,
[l1, l2],
prop=LEGEND_FP,
loc='upper center',
ncol=1,
bbox_to_anchor=(0.55, 1.3
), shadow=False,
columnspacing=0.1,
frameon=True, borderaxespad=-1.5, handlelength=1.2,
handletextpad=0.1,
labelspacing=0.1)
plt.yticks(rotation=0, size=TICK_FONT_SIZE)
plt.tight_layout()

plt.savefig(fname + ".pdf")
Loading

0 comments on commit a01d169

Please sign in to comment.