--topo-order
This commit is contained in:
parent
a91ab94771
commit
33d8daee79
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -2,6 +2,9 @@
|
||||
"python.analysis.typeCheckingMode": "basic",
|
||||
"python.formatting.blackArgs": ["--line-length", "120"],
|
||||
"isort.args": ["--profile", "black"],
|
||||
"search.exclude": {
|
||||
"**/venv": true,
|
||||
},
|
||||
"python.analysis.extraPaths": [
|
||||
"xmetrics"
|
||||
]
|
||||
|
8
pyrightconfig.json
Normal file
8
pyrightconfig.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"exclude": [
|
||||
"**/node_modules",
|
||||
"**/__pycache__",
|
||||
"**/build/lib",
|
||||
"**/venv"
|
||||
]
|
||||
}
|
@ -5,8 +5,7 @@ FROM metrics-base as metrics-tmg
|
||||
RUN git clone https://github.com/OnGoTeam/TMGmod.git repo
|
||||
WORKDIR /code/repo/
|
||||
RUN git fetch && git checkout 82db35f2db92572c98d84ef781f64f8d65d2f023
|
||||
ENV SRCDIR="build/src"
|
||||
ENV SRCPATTERN="*.cs"
|
||||
ENV SRCPATTERN="./build/src/**/*.cs"
|
||||
|
||||
FROM metrics-base as metrics-radn
|
||||
RUN git clone https://gitea.parrrate.ru/PTV/radn-rs.git repo
|
||||
@ -37,17 +36,16 @@ FROM metrics-base as metrics-ocen
|
||||
RUN git clone https://github.com/ocen-lang/ocen.git repo
|
||||
WORKDIR /code/repo/
|
||||
RUN git fetch && git checkout 0b1a63d0e141fc3032f10c70b5cae117429e2dcb
|
||||
ENV SRCDIR="."
|
||||
ENV SRCPATTERN="*.[oa][ec]"
|
||||
ENV SRCPATTERN="./**/*.[oa][ec]"
|
||||
|
||||
FROM metrics-base as metrics-aecor
|
||||
RUN git clone https://github.com/mustafaquraish/aecor.git repo
|
||||
WORKDIR /code/repo/
|
||||
RUN git fetch && git checkout f81543a34ee363dcc00e8632fd7cfcd4a3478b23
|
||||
ENV SRCDIR="."
|
||||
ENV SRCPATTERN="*.[ach]*"
|
||||
ENV SRCPATTERN="./**/*.[ach]*"
|
||||
|
||||
FROM metrics-cargo as metrics-repo
|
||||
FROM metrics-rust as metrics-repo
|
||||
|
||||
FROM metrics-repo as metrics-commits
|
||||
COPY common.py /code/common.py
|
||||
@ -60,9 +58,8 @@ COPY metrics.py /code/metrics.py
|
||||
COPY --from=metrics-commits /code/commits.dat commits.dat
|
||||
RUN python3 /code/metrics.py
|
||||
|
||||
FROM python:3.11 as metrics-process
|
||||
FROM metrics-base as metrics-process
|
||||
RUN python3 -m pip install numpy
|
||||
WORKDIR /code/
|
||||
|
||||
FROM metrics-process as metrics-data
|
||||
COPY --from=metrics /code/metrics.dat metrics.dat
|
||||
@ -90,13 +87,14 @@ FROM metrics-c as metrics-c-proportional
|
||||
COPY c_proportional.py c_proportional.py
|
||||
RUN python3 c_proportional.py
|
||||
|
||||
FROM metrics-process as metrics-x-linear
|
||||
FROM metrics-process as metrics-x
|
||||
COPY --from=metrics-y /code/Y.dat Y.dat
|
||||
|
||||
FROM metrics-x as metrics-x-linear
|
||||
COPY x_linear.py x_linear.py
|
||||
RUN python3 x_linear.py
|
||||
|
||||
FROM metrics-process as metrics-x-proportional
|
||||
COPY --from=metrics-y /code/Y.dat Y.dat
|
||||
FROM metrics-x as metrics-x-proportional
|
||||
COPY x_proportional.py x_proportional.py
|
||||
RUN python3 x_proportional.py
|
||||
|
||||
@ -127,8 +125,7 @@ COPY --from=metrics-x-proportional /code/X.dat X.dat
|
||||
COPY --from=metrics-c-proportional /code/C.dat C.dat
|
||||
RUN python3 render_hist.py
|
||||
|
||||
FROM metrics-render
|
||||
COPY --from=metrics-y /code/Y.dat Y.dat
|
||||
FROM metrics-base
|
||||
COPY --from=metrics-render-ploc /code/metrics/out.png /code/metrics/metrics.png
|
||||
COPY --from=metrics-render-01x /code/metrics/out.png /code/metrics/metrics-01x.png
|
||||
COPY --from=metrics-render-02y /code/metrics/out.png /code/metrics/metrics-02y.png
|
||||
|
@ -2,18 +2,22 @@ import pickle
|
||||
from random import randrange
|
||||
from subprocess import check_output
|
||||
|
||||
from common import counter
|
||||
from common import set_
|
||||
|
||||
BITS = 2
|
||||
|
||||
BITS = 7
|
||||
|
||||
def mask(height: int) -> int:
|
||||
return ((1 << height.bit_length()) - 1) >> BITS
|
||||
|
||||
|
||||
def valid(commit: str, height: int) -> bool:
|
||||
expected = int.from_bytes(bytes.fromhex(commit), "little")
|
||||
return mask(height) & (height ^ expected) == 0
|
||||
|
||||
args = []
|
||||
|
||||
# args = []
|
||||
args = ["--topo-order"]
|
||||
original_commits = check_output(["git", "log", "--pretty=%H", *args], text=True).splitlines()
|
||||
N = len(original_commits)
|
||||
total_changes: dict[str, tuple[int, int]] = {}
|
||||
@ -28,11 +32,11 @@ for i, commit in enumerate(reversed(original_commits)):
|
||||
chosen_parent = None
|
||||
height = 1 + max((heights[parent] for parent in parents), default=0)
|
||||
nheight = 1 + min((nheights[parent] for parent in parents), default=0)
|
||||
if valid(commit, height) or nheight > mask(height):
|
||||
if nheight > mask(height) or valid(commit, height):
|
||||
included.add(commit)
|
||||
nheight = 0
|
||||
ctr = counter(commit, True)
|
||||
changes = ctr.total(), 1
|
||||
ctr = set_(commit)
|
||||
changes = len(ctr), 1
|
||||
for parent in parents:
|
||||
if parent in included:
|
||||
_parent = parent
|
||||
@ -41,9 +45,9 @@ for i, commit in enumerate(reversed(original_commits)):
|
||||
if _parent is None:
|
||||
continue
|
||||
assert _parent in included
|
||||
pctr = counter(_parent, True)
|
||||
pctr = set_(_parent)
|
||||
pcc, pch = total_changes[parent]
|
||||
maybe_changes = (pctr - ctr).total() + (ctr - pctr).total() + pcc, pch + 1
|
||||
maybe_changes = len(pctr - ctr) + len(ctr - pctr) + pcc, pch + 1
|
||||
if maybe_changes > changes:
|
||||
changes = maybe_changes
|
||||
chosen_parent = parent
|
||||
|
@ -6,22 +6,30 @@ from subprocess import check_output
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def _counter(commit: str, unique: bool) -> Counter:
|
||||
def _counter(commit: str, unique: bool, to_counter: bool) -> Counter | set:
|
||||
check_output(["git", "checkout", commit], text=True)
|
||||
if unique:
|
||||
all_lines = set()
|
||||
else:
|
||||
all_lines = Counter()
|
||||
for path in Path(os.getenv("SRCDIR", "src")).rglob(os.getenv("SRCPATTERN", "*.rs")):
|
||||
for path in Path.cwd().rglob(os.getenv("SRCPATTERN", "./src/**/*.rs")):
|
||||
lines = path.read_bytes().splitlines()
|
||||
lines = (line.strip() for line in lines)
|
||||
lines = (line for line in lines if line)
|
||||
all_lines.update(lines)
|
||||
if isinstance(all_lines, set):
|
||||
if isinstance(all_lines, set) and to_counter:
|
||||
return Counter(all_lines)
|
||||
else:
|
||||
return all_lines
|
||||
|
||||
|
||||
def set_(commit: str) -> set:
|
||||
all_lines = _counter(commit, True, False)
|
||||
assert isinstance(all_lines, set)
|
||||
return all_lines
|
||||
|
||||
|
||||
def counter(commit: str, unique: bool) -> Counter:
|
||||
return _counter(commit, unique)
|
||||
all_lines = _counter(commit, unique, True)
|
||||
assert isinstance(all_lines, Counter)
|
||||
return all_lines
|
||||
|
@ -13,7 +13,7 @@ C = min(len(commits), 720)
|
||||
for i, commit in enumerate(reversed(commits)):
|
||||
print(f"P={i / len(commits):6f}", flush=True)
|
||||
print("running", commit, flush=True)
|
||||
current_ctr = counter(commit, False)
|
||||
current_ctr = counter(commit, True)
|
||||
added = current_ctr - last_ctr
|
||||
deleted = last_ctr - current_ctr
|
||||
entries.append((i, current_ctr.total(), added.total(), deleted.total()))
|
||||
|
Loading…
Reference in New Issue
Block a user