Skip to content

Commit ba284f5

Browse files
committed
update repo testing code
1 parent 2142dc6 commit ba284f5

File tree

2 files changed

+59
-8
lines changed

2 files changed

+59
-8
lines changed

tests/python/draw_git_test_plots.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import os
2+
import glob
3+
import pandas as pd
4+
import matplotlib.pyplot as plt
5+
import numpy as np
6+
def plot_data_from_file(file_path):
7+
# Load the data, assuming the last column is text
8+
data = pd.read_csv(file_path, header=None)
9+
rep_size=len(set(data[data.columns[-1]]))
10+
data.drop(data.columns[-1], axis=1, inplace=True) # Drop the last column (text)
11+
12+
# Number of numerical columns
13+
num_columns = data.shape[1]
14+
15+
# Create a subplot for each column
16+
fig, axes = plt.subplots(num_columns, 1, figsize=(10, 6 * num_columns))
17+
18+
# In case there is only one column, axes will not be an array, so we convert it
19+
if num_columns == 1:
20+
axes = [axes]
21+
22+
for i, ax in enumerate(axes):
23+
idx=0
24+
ax.scatter(np.asarray(data.index,dtype=np.int64)%rep_size, data[i], label=f'Column {i+1}')
25+
ax.set_title(f'Column {i+1}')
26+
ax.set_xlabel('ID Number')
27+
ax.set_ylabel('Value')
28+
ax.legend()
29+
ax.grid(True)
30+
31+
plt.tight_layout()
32+
plt.suptitle(f'Data from {os.path.basename(file_path)}')
33+
34+
# Save the plot to a file
35+
plt.savefig(file_path.replace('.txt', '.png'))
36+
plt.close()
37+
38+
def scan_and_plot(directory):
39+
# Scan for .txt files in the given directory
40+
txt_files = glob.glob(os.path.join(directory, '*.txt'))
41+
42+
# Process each file
43+
for file in txt_files:
44+
print(f'Processing {file}...')
45+
plot_data_from_file(file)
46+
print(f'Plot saved for {file}')
47+
# Replace 'your_folder_path' with the path to the folder containing the .txt files
48+
scan_and_plot('./')

tests/python/git_tester.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
speedtest_copy_path = os.path.join("tests", "python", "speedtest2.py")
1010
shutil.copyfile(speedtest_src_path, speedtest_copy_path) # the file has to be outside of git
1111

12-
commits = list(Repository('.', from_tag="v0.6.2").traverse_commits())
12+
commits = list(Repository('.', from_tag="v0.7.0").traverse_commits())
1313
print("Found commits:")
1414
for idx, commit in enumerate(commits):
1515
name = commit.msg.replace('\n', ' ').replace('\r', ' ')
1616
print(idx, commit.hash, name)
1717

1818
for commit in commits:
19-
name = commit.msg.replace('\n', ' ').replace('\r', ' ').replace(",", ";")
19+
commit_time = commit.author_date.strftime("%Y-%m-%d %H:%M:%S")
20+
author_name = commit.author.name
21+
name = "auth:"+author_name+"_"+commit_time+"_msg:"+commit.msg.replace('\n', ' ').replace('\r', ' ').replace(",", ";")
2022
print("\nProcessing", commit.hash, name)
21-
23+
2224
if os.path.exists("build"):
2325
shutil.rmtree("build")
2426
os.system(f"git checkout {commit.hash}")
@@ -43,10 +45,11 @@
4345
print("build failed!!!!")
4446
continue
4547

46-
# os.system(f'python {speedtest_copy_path} -n "{hash[:4]}_{name}" -d 32 -t 1')
48+
4749
os.system(f'python {speedtest_copy_path} -n "{commit.hash[:4]}_{name}" -d 16 -t 1')
4850
os.system(f'python {speedtest_copy_path} -n "{commit.hash[:4]}_{name}" -d 16 -t 64')
49-
# os.system(f'python {speedtest_copy_path} -n "{name}" -d 64 -t 1')
50-
# os.system(f'python {speedtest_copy_path} -n "{name}" -d 128 -t 1')
51-
# os.system(f'python {speedtest_copy_path} -n "{name}" -d 4 -t 24')
52-
# os.system(f'python {speedtest_copy_path} -n "{name}" -d 128 -t 24')
51+
os.system(f'python {speedtest_copy_path} -n "{commit.hash[:4]}_{name}" -d 4 -t 1')
52+
os.system(f'python {speedtest_copy_path} -n "{commit.hash[:4]}_{name}" -d 4 -t 64')
53+
os.system(f'python {speedtest_copy_path} -n "{commit.hash[:4]}_{name}" -d 128 -t 1')
54+
os.system(f'python {speedtest_copy_path} -n "{commit.hash[:4]}_{name}" -d 128 -t 64')
55+

0 commit comments

Comments
 (0)