Skip to content

measure loading xpath.pl library loading time#349

Merged
nlothian merged 1 commit intomainfrom
feature/time-load
Dec 13, 2025
Merged

measure loading xpath.pl library loading time#349
nlothian merged 1 commit intomainfrom
feature/time-load

Conversation

@nlothian
Copy link
Copy Markdown
Owner

No description provided.

@nlothian nlothian merged commit fe647c3 into main Dec 13, 2025
2 checks passed
Copy link
Copy Markdown

@kilo-code-bot kilo-code-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No Issues Found

2 files reviewed | Confidence: 100% | Recommendation: Merge

Review Details

Files: docs/xpath_library_load_times.csv, tools/measure_xpath_load_time.py

Checked: Security, bugs, performance, error handling

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a script to measure and log the loading time of the xpath.pl library. The approach is sound, but the script could be made more robust with better error handling for the external commands it runs. I've added a couple of suggestions to catch potential exceptions and provide clearer error messages to the user. This will make the tool more reliable and easier to debug.

Comment on lines +18 to +24
result = subprocess.run(
["git", "rev-parse", "--short", "HEAD"],
cwd=repo_root,
check=True,
capture_output=True,
text=True,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The script will crash with an unhandled exception if the git command fails (e.g., if git is not installed, or this is not a git repository). It's better to catch potential subprocess.CalledProcessError and FileNotFoundError exceptions and print a user-friendly error message before exiting. This requires importing the sys module at the top of the file (e.g., import sys).

Suggested change
result = subprocess.run(
["git", "rev-parse", "--short", "HEAD"],
cwd=repo_root,
check=True,
capture_output=True,
text=True,
)
try:
result = subprocess.run(
["git", "rev-parse", "--short", "HEAD"],
cwd=repo_root,
check=True,
capture_output=True,
text=True,
)
except (FileNotFoundError, subprocess.CalledProcessError) as e:
print(f"Error: Failed to get git commit hash.", file=sys.stderr)
print(f"Details: {e}", file=sys.stderr)
if isinstance(e, subprocess.CalledProcessError):
print(f"Stderr: {e.stderr}", file=sys.stderr)
sys.exit(1)

"""Run xpath library load command and return elapsed seconds."""
command = ["uv", "run", "vibeprolog.py", "./library/xpath.pl", '-q', 'true.']
start = time.perf_counter()
subprocess.run(command, cwd=repo_root, check=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This subprocess.run call can fail if uv is not found (FileNotFoundError) or if the command returns a non-zero exit code (CalledProcessError). It's good practice to handle these potential errors and provide a clear error message. For better diagnostics, consider capturing the output and printing stderr on failure. This requires importing the sys module.

Suggested change
subprocess.run(command, cwd=repo_root, check=True)
try:
# Capture output to provide more context on error
subprocess.run(command, cwd=repo_root, check=True, capture_output=True, text=True)
except (FileNotFoundError, subprocess.CalledProcessError) as e:
print("Error: Failed to run xpath load measurement.", file=sys.stderr)
print(f"Details: {e}", file=sys.stderr)
if isinstance(e, subprocess.CalledProcessError):
print(f"Stderr: {e.stderr}", file=sys.stderr)
sys.exit(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant