{{ message }}
Docstring perf#5686
Closed
aaltat wants to merge 2 commits into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new docstring parser (robot.running.docstring.parse_docstring) with extensive unit tests, plus a standalone benchmark script intended to measure parser performance in different Robot Framework-related scenarios.
Changes:
- Added
ParsedDocStringdataclass andparse_docstring()implementation for parsing Google-styleArgs:/Returns:sections. - Added comprehensive unit tests covering plain prose, structured sections, malformed inputs, indentation edge cases, and RF variable syntax.
- Added a performance benchmark script under
utest/perfto time/allocate/profile different benchmark phases.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+39
to
+45
| def parse_docstring(doc: str) -> ParsedDocString: | ||
| """Always returns a ParsedDocString — never raises.""" | ||
| try: | ||
| return _parse(doc) | ||
| except (TypeError, AttributeError): | ||
| return ParsedDocString(doc="", args={}, returns="") | ||
|
|
Comment on lines
+9
to
+12
| libdoc — calls ``LibraryDocumentation(path)`` on a generated library. | ||
| This is the *only* RF execution phase that actually calls | ||
| ``parse_docstring`` (via KeywordImplementation.update_docs). | ||
|
|
Comment on lines
+13
to
+16
| rf_import — imports the library via RF's own ``TestLibrary.from_name`` | ||
| (the same path used during test execution). Confirms that | ||
| ``parse_docstring`` is NOT called during library import — that | ||
| only happens in the libdoc phase. |
Comment on lines
+334
to
+336
| # 2. libdoc (the only RF path that calls parse_docstring) | ||
| if baseline and _KW_IMPL_HAS_PARSE: | ||
| _kw_impl.parse_docstring = _noop_parse |
Comment on lines
+345
to
+347
| # 3. RF library import (no parse_docstring — only in libdoc) | ||
| s = _measure_many(lambda p=lib_path: _run_rf_import(p), runs) | ||
| _print_entry("rf_import", style, s, runs) |
Comment on lines
+350
to
+353
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

There is simple performance script and I made some measurements.
No idea is this good way to test perf or would be there be a better way. But now there is starting point to discuss.