commit time metrics

This commit is contained in:
AF 2023-06-30 23:20:52 +00:00
parent ecd7283daa
commit 9b2eaf9fe2
5 changed files with 56 additions and 2 deletions

1
.gitignore vendored
View File

@ -160,3 +160,4 @@ cython_debug/
#.idea/ #.idea/
*.png *.png
commits.json

26
commits/commits.py Normal file
View File

@ -0,0 +1,26 @@
import asyncio
import json
import aiohttp
async def main():
pages = []
async with aiohttp.ClientSession() as session:
i = 1
while True:
async with session.get(
f"https://gitea.parrrate.ru/api/v1/repos/PTV/radn-rs/commits?stat=true&page={i}",
headers={"accept": "application/json"},
) as response:
page = await response.json()
if not page:
break
pages.extend(page)
print(i)
i += 1
with open("commits.json", "w") as file:
json.dump(pages, file, indent=2)
asyncio.run(main())

28
commits/commits2.py Normal file
View File

@ -0,0 +1,28 @@
import json
from datetime import datetime
from itertools import pairwise
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams["figure.figsize"] = [18, 9]
plt.style.use("dark_background")
plt.subplots_adjust(left=0.05, right=0.99, top=0.95, bottom=0.05)
with open("commits.json", "r") as file:
pages = json.load(file)
times = []
for commit in pages:
times.append(datetime.strptime(commit["created"], "%Y-%m-%dT%H:%M:%SZ"))
deltas = []
for a, b in pairwise(times):
deltas.append((a - b))
deltas.sort()
print("start")
for delta in deltas:
print(delta)
X = np.arange(len(deltas))
Y = np.array([delta.total_seconds() for delta in deltas])
plt.gca().set_yscale("log")
plt.scatter(X, Y, s=2.0)
plt.savefig("commits.png")

View File

@ -3,7 +3,7 @@ RUN cargo install rust-code-analysis-cli
WORKDIR /code/ WORKDIR /code/
RUN git clone https://gitea.parrrate.ru/PTV/radn-rs.git RUN git clone https://gitea.parrrate.ru/PTV/radn-rs.git
WORKDIR /code/radn-rs/ WORKDIR /code/radn-rs/
RUN git fetch && git checkout de26092abcc44fa249bbbfd0309613783107af52 RUN git fetch && git checkout 540fdce02aefcb0dae5735c55daec690c4571b18
COPY metrics.py /code/metrics.py COPY metrics.py /code/metrics.py
RUN python3 /code/metrics.py RUN python3 /code/metrics.py
FROM python:3.11 FROM python:3.11

View File

@ -1,4 +1,3 @@
import gc
import json import json
import matplotlib.pyplot as plt import matplotlib.pyplot as plt