framework/profile: don't deepcopy when copying profiles

Submitted by Dylan Baker on Nov. 15, 2016, 9:08 p.m.

Details

Message ID 20161115210859.31559-1-dylan@pnwbakers.com
State New
Headers show
Series "framework/profile: don't deepcopy when copying profiles" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Dylan Baker Nov. 15, 2016, 9:08 p.m.
This reduces memory consumption by a lot (about 60% on my system), which
fixes some tests that fail sporadically on low memory systems.

cc: Mark Janes <mark.a.janes@intel.com>
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
---
 framework/profile.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/framework/profile.py b/framework/profile.py
index 23abc6d..56f017b 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -297,12 +297,11 @@  class TestProfile(object):
         """Create a copy of the TestProfile.
 
         This method creates a copy with references to the original instance
-        (using copy.copy), except for the test_list attribute, which is copied
-        using copy.deepcopy. This allows profiles to be "subclassed" by other
-        profiles, without modifying the original.
+        using copy.copy.deepcopy. This allows profiles to be "subclassed" by
+        other profiles, without modifying the original.
         """
         new = copy.copy(self)
-        new.test_list = copy.deepcopy(self.test_list)
+        new.test_list = copy.copy(self.test_list)
         new.forced_test_list = copy.copy(self.forced_test_list)
         new.filters = copy.copy(self.filters)
         return new

Comments

Quoting Dylan Baker (2016-11-15 13:08:59)
> This reduces memory consumption by a lot (about 60% on my system), which
> fixes some tests that fail sporadically on low memory systems.
> 
> cc: Mark Janes <mark.a.janes@intel.com>
> Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
> ---
>  framework/profile.py | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/framework/profile.py b/framework/profile.py
> index 23abc6d..56f017b 100644
> --- a/framework/profile.py
> +++ b/framework/profile.py
> @@ -297,12 +297,11 @@ class TestProfile(object):
>          """Create a copy of the TestProfile.
>  
>          This method creates a copy with references to the original instance
> -        (using copy.copy), except for the test_list attribute, which is copied
> -        using copy.deepcopy. This allows profiles to be "subclassed" by other
> -        profiles, without modifying the original.
> +        using copy.copy.deepcopy. This allows profiles to be "subclassed" by

oops, the ".deepcopy" is a typo. I've fixed that locally.

> +        other profiles, without modifying the original.
>          """
>          new = copy.copy(self)
> -        new.test_list = copy.deepcopy(self.test_list)
> +        new.test_list = copy.copy(self.test_list)
>          new.forced_test_list = copy.copy(self.forced_test_list)
>          new.filters = copy.copy(self.filters)
>          return new
> -- 
> 2.10.2
>
Tested-by: Mark Janes <mark.a.janes@intel.com>
Reviewed-by: Mark Janes <mark.a.janes@intel.com>

Dylan Baker <dylan@pnwbakers.com> writes:

> This reduces memory consumption by a lot (about 60% on my system), which
> fixes some tests that fail sporadically on low memory systems.
>
> cc: Mark Janes <mark.a.janes@intel.com>
> Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
> ---
>  framework/profile.py | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/framework/profile.py b/framework/profile.py
> index 23abc6d..56f017b 100644
> --- a/framework/profile.py
> +++ b/framework/profile.py
> @@ -297,12 +297,11 @@ class TestProfile(object):
>          """Create a copy of the TestProfile.
>  
>          This method creates a copy with references to the original instance
> -        (using copy.copy), except for the test_list attribute, which is copied
> -        using copy.deepcopy. This allows profiles to be "subclassed" by other
> -        profiles, without modifying the original.
> +        using copy.copy.deepcopy. This allows profiles to be "subclassed" by
> +        other profiles, without modifying the original.
>          """
>          new = copy.copy(self)
> -        new.test_list = copy.deepcopy(self.test_list)
> +        new.test_list = copy.copy(self.test_list)
>          new.forced_test_list = copy.copy(self.forced_test_list)
>          new.filters = copy.copy(self.filters)
>          return new
> -- 
> 2.10.2