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

PMEM: Optimization of enabled namespace methods #5873

Closed
wants to merge 1 commit into from

Conversation

ut003460
Copy link
Contributor

  1. Optimized the string connection section. Optimize repeated string concatenation operations into one-time concatenation instead of appending strings each time
  2. Replace subprocess.check_call with os.system to ensure that the code maintains its original functionality while improving execution efficiency to a certain extent

Copy link
Contributor

@richtja richtja left a comment

Choose a reason for hiding this comment

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

Hi @ut003460, thank you for this. I wrote a few comments here, but my main concern is about changing the process.system to os.system. Can you please provide me more info about why this change is needed, because maybe I am missing something here? Thank you

avocado/utils/pmem.py Outdated Show resolved Hide resolved
avocado/utils/pmem.py Show resolved Hide resolved
avocado/utils/pmem.py Outdated Show resolved Hide resolved
avocado/utils/pmem.py Outdated Show resolved Hide resolved
avocado/utils/pmem.py Show resolved Hide resolved
1. Optimized the string connection section. Optimize repeated string concatenation operations into one-time concatenation instead of appending strings each time
2. Replace subprocess.check_call with os.system to ensure that the code maintains its original functionality while improving execution efficiency to a certain extent

Signed-off-by: ut003460 <xiongneng@uniontech.com>
Copy link
Contributor

@richtja richtja left a comment

Choose a reason for hiding this comment

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

Hi @ut003460 thank you for your updates. IMO, It is almost done. I just hove one small comment to docstring.

@@ -265,12 +265,10 @@ def enable_region(self, name="all"):
def disable_namespace(self, namespace="all", region="", bus="", verbose=False):
"""
Disable namespaces

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please return the new lines into this docstring. It improves the readability, and it will be in respect to PEP 257

:param namespace: name of the namespace to be disabled
:param region: Filter namespace by region
:param bus: Filter namespace by bus
:param verbose: Enable True command with debug information

Copy link
Contributor

Choose a reason for hiding this comment

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

same here

if bus:
args = f"{args} -b {bus}"
args += f" -b {bus}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, you're adding on operation here. Initially you have one "f string" operation (with two variables). Now you have both, one "f string" and a string concatenation.

I'm sorry but this is not an optimization.

Even worse, there's a consensus around the fact that usually string concatenations are slower than "f string" operations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not a very good optimization, thank you for your comment

@ut003460 ut003460 closed this Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants