Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce script to measure the duration of the formal verification #373

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions misc/formal_verification_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import re
import subprocess
import time

def extract_kani_names(file_path):
pattern = re.compile(
r"#\[cfg_attr\(kani, kani::proof\)\]\s*"
r"#\[cfg_attr\(test, test\)\]\s*"
r"pub fn (\w+)\s*\("
)

with open(file_path, 'r') as file:
content = file.read()

return pattern.findall(content)

def time_cargo_run(subcommand):
command = ["cargo", "run", "--", "verify", subcommand]

start_time = time.time()

try:
with open('/dev/null', 'w') as devnull:
subprocess.run(command, check=True, stdout=devnull, stderr=devnull)
except subprocess.CalledProcessError as e:
print(f"Command failed with return code {e.returncode}")

duration = time.time() - start_time

print(f"{subcommand} verification completed in {duration:.2f} seconds.")

return duration

if __name__ == "__main__":
print("Please run the script from the miralis folder, otherwise it won't work.")

file_path = "model_checking/src/lib.rs"
functions = extract_kani_names(file_path)

for func in functions:
time_cargo_run(func)