-
Notifications
You must be signed in to change notification settings - Fork 62
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
Benchmark python specfile a bit #2777
Comments
@xsuchy claims it is non-problem |
from specfile import Specfile
import time
specfile_path = "texlive.spec"
script_start = start = time.time()
def benchmark(message):
global start
now = time.time()
print(f"{message}: {now-start} seconds")
start = now
spec = Specfile(specfile_path)
benchmark("loaded")
print(spec.expanded_name)
benchmark("name parsed")
print(spec.expanded_epoch)
benchmark("epoch parsed")
print(spec.expanded_version)
benchmark("version parsed")
print(spec.expanded_release)
benchmark("release parsed")
print(f"The script took {time.time() - script_start} seconds") Running the script, it hangs for a few minutes here:
|
Continues:
|
Memory consumption 827M, seems acceptable for the builder, not sure about backend. |
I accidentally canceled the terminal, but the epoch was parsed after another ~1750s. On |
Sorry, this is crazy. Let me try to do some optimizations. |
With packit/specfile#240, on my laptop:
To make it faster, you can do this (to parse tags only once): spec = Specfile(specfile_path)
benchmark("loaded")
tags = spec.tags().content
print(tags.name.expanded_value)
benchmark("name parsed")
print(tags.epoch.expanded_value)
benchmark("epoch parsed")
print(tags.version.expanded_value)
benchmark("version parsed")
print(tags.release.expanded_value)
benchmark("release parsed")
print(f"The script took {time.time() - script_start} seconds") Result:
|
Oh, and to get release without the dist tag, you can do: print(spec.expand(tags.release.value, extra_macros=[("dist", "")])) But it will slow things down a bit again:
|
Nice, thank you for the fix, @nforro! This is likely one of the worst scenarios, and if we can parse such a spec file in less than a minute, it is more than good. |
Once in stable, we should |
Jakub promised to specify the specific version in our specfiles once it is in stable (changed assignee). |
#2800 fixes this |
We are going to process all spec files with python-specfile now. We already count with parse errors, though parsing might be really expensivefor some packages. We should test it on texlive.spec e.g.
The text was updated successfully, but these errors were encountered: