mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
fix: Add elapsed time logging to print statements
This commit is contained in:
parent
042a4f14d2
commit
276b30506c
1 changed files with 16 additions and 6 deletions
|
@ -3,6 +3,7 @@ import math
|
|||
import os
|
||||
import random
|
||||
import sys
|
||||
import time
|
||||
import warnings
|
||||
from collections import Counter, defaultdict, namedtuple
|
||||
from importlib import resources
|
||||
|
@ -23,6 +24,15 @@ from aider.dump import dump # noqa: F402,E402
|
|||
|
||||
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"{message}: {elapsed:.2f} seconds")
|
||||
else:
|
||||
print(f"{message}: (first measurement)")
|
||||
print_elapsed.last_time = current_time
|
||||
|
||||
|
||||
class RepoMap:
|
||||
CACHE_VERSION = 3
|
||||
|
@ -246,7 +256,7 @@ class RepoMap:
|
|||
fnames = tqdm(fnames)
|
||||
self.cache_missing = False
|
||||
|
||||
print('tags')
|
||||
print_elapsed('Starting tags processing')
|
||||
|
||||
for fname in fnames:
|
||||
if not Path(fname).is_file():
|
||||
|
@ -284,7 +294,7 @@ class RepoMap:
|
|||
elif tag.kind == "ref":
|
||||
references[tag.name].append(rel_fname)
|
||||
|
||||
print('graph')
|
||||
print_elapsed('Finished tags processing, starting graph creation')
|
||||
##
|
||||
# dump(defines)
|
||||
# dump(references)
|
||||
|
@ -325,13 +335,13 @@ class RepoMap:
|
|||
else:
|
||||
pers_args = dict()
|
||||
|
||||
print('rank')
|
||||
print_elapsed('Starting pagerank calculation')
|
||||
try:
|
||||
ranked = nx.pagerank(G, weight="weight", **pers_args)
|
||||
except ZeroDivisionError:
|
||||
return []
|
||||
|
||||
print('dist rank')
|
||||
print_elapsed('Starting rank distribution')
|
||||
|
||||
# distribute the rank from each source node, across all of its out edges
|
||||
ranked_definitions = defaultdict(float)
|
||||
|
@ -349,7 +359,7 @@ class RepoMap:
|
|||
|
||||
# dump(ranked_definitions)
|
||||
|
||||
print('ranked_tags')
|
||||
print_elapsed('Starting ranked tags processing')
|
||||
for (fname, ident), rank in ranked_definitions:
|
||||
# print(f"{rank:.03f} {fname} {ident}")
|
||||
if fname in chat_rel_fnames:
|
||||
|
@ -370,7 +380,7 @@ class RepoMap:
|
|||
for fname in rel_other_fnames_without_tags:
|
||||
ranked_tags.append((fname,))
|
||||
|
||||
print('done')
|
||||
print_elapsed('Finished processing')
|
||||
return ranked_tags
|
||||
|
||||
def get_ranked_tags_map(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue