68 lines
1.7 KiB
Python
Executable File
68 lines
1.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import glob
|
|
from datetime import datetime
|
|
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
def load(path):
|
|
data = []
|
|
for file in glob.glob(path):
|
|
with open(file, 'r') as f:
|
|
inp = f.readlines()
|
|
data.append((datetime.fromtimestamp(float(file[6:-4])), float(inp[1][10:-1])))
|
|
# data[datetime.fromtimestamp(float(file[6:-4]))] = float(inp[1][10:-1])
|
|
|
|
return sorted(data, key=lambda x: x[0])
|
|
|
|
def read(path):
|
|
data = []
|
|
with open(path, 'r') as f:
|
|
data.extend(map(float, f.readlines()))
|
|
|
|
return data
|
|
|
|
# ranks = [0.25, 0.5, 0.75]
|
|
# iterations = 5
|
|
|
|
# for rank in ranks:
|
|
# for iteration in range(iterations):
|
|
# count, bins, ignored = plt.hist(read(f'./{rank}_{iteration+1}_sr.txt'), 30)
|
|
# plt.xlabel('SensorRank')
|
|
# plt.ylabel('Peers')
|
|
# s = 's'
|
|
# e = ''
|
|
# plt.title(f'SensorRank distribution after {iteration+1} iteration{s if iteration+1 > 1 else e} with initial rank {rank}')
|
|
# plt.savefig(f'./{rank:.2f}_{iteration+1}_sr.png')
|
|
# plt.clf()
|
|
# plt.cla()
|
|
|
|
|
|
# count, bins, ignored = plt.hist(data, 30)
|
|
# # plt.show()
|
|
# # plt.imsave("", data)
|
|
# plt.xlabel('PageRank')
|
|
# plt.ylabel('peers')
|
|
# plt.title()
|
|
# plt.savefig('./0.25_5_sr.png')
|
|
|
|
def main():
|
|
data = load('./inp/*')
|
|
N = len(data)
|
|
# for x in data:
|
|
# print(x)
|
|
# exit(1)
|
|
fig, ax = plt.subplots(figsize=(8, 4))
|
|
ax.plot([v[0] for v in data], [v[1] for v in data])
|
|
# ax.plot([v[0] for v in data], [v[1] for v in data], 'o-')
|
|
ax.set_title('Average outgoing edges per peer per hour')
|
|
ax.set_ylim(ymin=0)
|
|
fig.autofmt_xdate()
|
|
|
|
# plt.show()
|
|
plt.savefig('./avg_out_edges_no_dot.png')
|
|
|
|
if __name__ == "__main__":
|
|
main()
|