fix: Remove all print_elapsed calls

This commit is contained in:
Paul Gauthier (aider) 2024-08-05 17:15:26 -03:00
parent b6760e26c7
commit 72ceb87acb

View file

@ -3,7 +3,6 @@ import math
import os import os
import random import random
import sys import sys
import time
import warnings import warnings
from collections import Counter, defaultdict, namedtuple from collections import Counter, defaultdict, namedtuple
from importlib import resources from importlib import resources
@ -25,16 +24,6 @@ from aider.dump import dump # noqa: F402,E402
Tag = namedtuple("Tag", "rel_fname fname line name kind".split()) Tag = namedtuple("Tag", "rel_fname fname line name kind".split())
def print_elapsed(message):
current_time = time.time()
if hasattr(print_elapsed, "last_time"):
elapsed = current_time - print_elapsed.last_time
print(f"... {elapsed:.2f} seconds")
print(message)
else:
print(f"{message}:")
print_elapsed.last_time = current_time
class RepoMap: class RepoMap:
CACHE_VERSION = 3 CACHE_VERSION = 3
@ -280,8 +269,6 @@ class RepoMap:
fnames = tqdm(fnames) fnames = tqdm(fnames)
self.cache_missing = False self.cache_missing = False
print_elapsed("Starting tags processing")
for fname in fnames: for fname in fnames:
if not Path(fname).is_file(): if not Path(fname).is_file():
if fname not in self.warned_files: if fname not in self.warned_files:
@ -318,7 +305,6 @@ class RepoMap:
elif tag.kind == "ref": elif tag.kind == "ref":
references[tag.name].append(rel_fname) references[tag.name].append(rel_fname)
print_elapsed("Finished tags processing, starting graph creation")
## ##
# dump(defines) # dump(defines)
# dump(references) # dump(references)
@ -359,14 +345,11 @@ class RepoMap:
else: else:
pers_args = dict() pers_args = dict()
print_elapsed("Starting pagerank calculation")
try: try:
ranked = nx.pagerank(G, weight="weight", **pers_args) ranked = nx.pagerank(G, weight="weight", **pers_args)
except ZeroDivisionError: except ZeroDivisionError:
return [] return []
print_elapsed("Starting rank distribution")
# distribute the rank from each source node, across all of its out edges # distribute the rank from each source node, across all of its out edges
ranked_definitions = defaultdict(float) ranked_definitions = defaultdict(float)
for src in G.nodes: for src in G.nodes:
@ -383,7 +366,6 @@ class RepoMap:
# dump(ranked_definitions) # dump(ranked_definitions)
print_elapsed("Starting ranked tags processing")
for (fname, ident), rank in ranked_definitions: for (fname, ident), rank in ranked_definitions:
# print(f"{rank:.03f} {fname} {ident}") # print(f"{rank:.03f} {fname} {ident}")
if fname in chat_rel_fnames: if fname in chat_rel_fnames:
@ -404,7 +386,6 @@ class RepoMap:
for fname in rel_other_fnames_without_tags: for fname in rel_other_fnames_without_tags:
ranked_tags.append((fname,)) ranked_tags.append((fname,))
print_elapsed("Finished processing")
return ranked_tags return ranked_tags
def get_ranked_tags_map( def get_ranked_tags_map(