Skip to content

Logging unexecuted keyword has unnecessary overhead if keywords are not found #5051

Closed

Description

@jeremytaylor14

In an initial effort to make my testing repo compatible with both SeleniumLibrary and Browser, I added some conditional logic to run specific keywords based on the library chosen at test execution. More specifically, I used a global variable ${AUTOMATION}, declared in an argument file, which determines the library used here.

Basic example:

IF   '${AUTOMATION}' == 'SeleniumLibrary'
    SeleniumLibrary.Keyword_1
    SeleniumLibrary.Keyword_2
    SeleniumLibrary.Keyword_3
ELSE IF  '${AUTOMATION}' == 'Browser'
    Browser.Keyword_1
    Browser.Keyword_2
    Browser.Keyword_3
END

Initial results with a converted test showed a degrade in performance. If SeleniumLibrary is used, the Browser keywords are not ran, but RF appears to hang on the unmet 'ELSE IF' condition for several seconds in this example:
rf7-0_slow_elseif

After some discussion in Slack, I believe it's been confirmed that the root cause is due to the Browser library not being imported, which is potentially causing some overhead on the RF side. When Browser library is not imported, I get the slowness, but if I import Browser, that slowness is eliminated and I get a much more expected result:
rf7-0_good_result

Reproducible in both RF 6.1.1 and RF 7.0.
Python 3.10.12
Ubuntu 22.04.3

Activity

  1. added this to the v7.0.1 milestone on Feb 25, 2024
  2. self-assigned this
    on Feb 25, 2024
  3. pekkaklarck commented on Feb 25, 2024

    @pekkaklarck
    Member

    This is why the problem occurs:

    • We want to log unexecuted IF/ELSE and TRY/EXCEPT branches to show what would have happened in different conditions.
    • In these branches we try to resolve used keywords so that we can show their origin. In other words, if you use Log, we resolve it and show BuiltIn.Log in the log file instead of just Log.
    • If a keyword isn't found, we log just whatever was used. The keyword wasn't executed so it not being found isn't considered an error.
    • When a keyword isn't found, we try to see are there some keywords that have a similar name and propose them in the resulting error message. This helps, for example, with typos.
    • Finding similar matches has some overhead.
    • In this particular case the error message is ignored so all the effort spent for finding similar matches is wasted.

    In the end the root cause is pretty much the same as in #4659. The fix is also the same, we just need to disable recommendations in this context.

  4. changed the title [-]Performance Issue with IF/ELSE Conditionals when keyword library is not imported[/-] [+]Going through unexecuted keyword has unnecessary overhead if keywords are not found[/+] on Feb 25, 2024
  5. added a commit that references this issue on Feb 25, 2024
    d3d2e2c
  6. added a commit that references this issue on Mar 19, 2024
    11b799c
  7. changed the title [-]Going through unexecuted keyword has unnecessary overhead if keywords are not found[/-] [+]Logging unexecuted keyword has unnecessary overhead if keywords are not found[/+] on Apr 4, 2024
  8. added theissue type on Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions