In [2]:
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
plain = [379, 325, 332, 342, 356, 360, 370, 354, 343, 357, 350, 373, 361, 354, 369, 377, 360, 354, 360, 351, 348, 351, 343, 360, 355, 364, 366, 352, 365, 361]
thread = [391.0, 237.0, 163.0, 104.0, 86.5, 89.4, 73.2, 64.2, 64.5, 51.5, 49.4, 46.4, 45.2, 50.0, 52.1, 45.6, 45.1, 44.9, 47.8, 45.1, 48.9, 49.1, 45.1, 45.3, 45.1, 49.3, 47.9, 45.5, 45.4, 45.5]
font_path = '/System/Library/Fonts/ヒラギノ角ゴシック W3.ttc' # macOSのヒラギノフォント
jp_font = fm.FontProperties(fname=font_path)
# Data for the graph
plain = [379, 325, 332, 342, 356, 360, 370, 354, 343, 357, 350, 373, 361, 354, 369]
freethread = [391.0, 237.0, 163.0, 104.0, 86.5, 89.4, 73.2, 64.2, 64.5, 51.5, 49.4, 46.4, 45.2, 50.0, 52.1,]
x = list(range(1, len(plain) + 1))
# Creating the line graph
plt.figure(figsize=(10, 6))
plt.plot(x, plain, marker='o', linestyle='-', label='Python3.13')
for i, value in enumerate(plain):
plt.text(x[i], value + 10, str(value), ha='center', fontsize=9) # マーカーの上に表示
plt.plot(x, freethread, marker='^', linestyle='-', label='Python3.13t')
for i, value in enumerate(freethread):
plt.text(x[i], value + 15, str(value), ha='center', fontsize=9) # マーカーの上に表示
plt.title("処理時間", fontsize=14, fontproperties=jp_font)
plt.xlabel("スレッド数", fontsize=12, fontproperties=jp_font)
plt.ylabel("処理時間(ms)", fontsize=12, fontproperties=jp_font)
plt.ylim(0, max(plain) + 50) # y軸の下限を0に設定
plt.grid(True)
plt.legend(prop=jp_font)
plt.show()
In [3]:
plain = [239, 227, 236, 234, 233, 227, 236, 244, 230, 232, 232, 239, 237, 233, 231]
freethread = [430.0, 239.0, 171.0, 127.0, 102.0, 95.4, 85.5, 75.0, 72.9, 66.8, 61.4, 59.2, 57.8, 55.1, 58.9,]
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
font_path = '/System/Library/Fonts/ヒラギノ角ゴシック W3.ttc' # macOSのヒラギノフォント
jp_font = fm.FontProperties(fname=font_path)
# Data for the graph
x = list(range(1, len(plain) + 1))
# Creating the line graph
plt.figure(figsize=(10, 6))
plt.plot(x, plain, marker='o', linestyle='-', label='Python3.13')
for i, value in enumerate(plain):
plt.text(x[i], value + 10, str(value), ha='center', fontsize=9) # マーカーの上に表示
plt.plot(x, freethread, marker='^', linestyle='-', label='Python3.13t')
for i, value in enumerate(freethread):
plt.text(x[i], value + 15, str(value), ha='center', fontsize=9) # マーカーの上に表示
plt.title("グローバル変数を利用した場合の処理時間", fontsize=14, fontproperties=jp_font)
plt.xlabel("スレッド数", fontsize=12, fontproperties=jp_font)
plt.ylabel("処理時間(ms)", fontsize=12, fontproperties=jp_font)
plt.ylim(0, max(freethread) + 50) # y軸の下限を0に設定
plt.grid(True)
plt.legend(prop=jp_font)
plt.show()