mirror of
https://github.com/A6-9V/MQL5-Google-Onedrive.git
synced 2026-04-10 22:30:56 +00:00
- Modified `scripts/review_pull_requests.py` to filter `git for-each-ref` output by unmerged branches. - Reduces algorithmic complexity from O(N) to O(M) where N is total branches and M is active branches. - Avoids expensive `ahead-behind` calculations for potentially thousands of stale merged branches.
29 lines
947 B
Python
29 lines
947 B
Python
|
|
import subprocess
|
|
import time
|
|
import sys
|
|
|
|
def run_command(cmd):
|
|
start = time.time()
|
|
subprocess.run(cmd, capture_output=True)
|
|
end = time.time()
|
|
return end - start
|
|
|
|
def main():
|
|
print("Benchmarking git commands...")
|
|
|
|
# Baseline: current implementation (all refs)
|
|
cmd_all = ["git", "for-each-ref", "--format=%(refname:short)|%(committerdate:iso8601)|%(ahead-behind:origin/main)", "refs/remotes/origin"]
|
|
time_all = run_command(cmd_all)
|
|
print(f"Time for all refs: {time_all:.4f}s")
|
|
|
|
# Optimized: only unmerged refs
|
|
cmd_unmerged = ["git", "for-each-ref", "--no-merged", "origin/main", "--format=%(refname:short)|%(committerdate:iso8601)|%(ahead-behind:origin/main)", "refs/remotes/origin"]
|
|
time_unmerged = run_command(cmd_unmerged)
|
|
print(f"Time for unmerged refs: {time_unmerged:.4f}s")
|
|
|
|
diff = time_all - time_unmerged
|
|
print(f"Difference: {diff:.4f}s")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|