* [PATCH] kunit: tool: simplify kconfig is_subset_of() logic
@ 2020-12-08 23:21 Daniel Latypov
2020-12-09 7:28 ` David Gow
2021-02-05 22:28 ` Brendan Higgins
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Latypov @ 2020-12-08 23:21 UTC (permalink / raw)
To: brendanhiggins
Cc: davidgow, linux-kernel, linux-kselftest, skhan, Daniel Latypov
Don't use an O(nm) algorithm* and make it more readable by using a dict.
*Most obviously, it does a nested for-loop over the entire other config.
A bit more subtle, it calls .entries(), which constructs a set from the
list for _every_ outer iteration.
Signed-off-by: Daniel Latypov <dlatypov@google.com>
---
tools/testing/kunit/kunit_config.py | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/tools/testing/kunit/kunit_config.py b/tools/testing/kunit/kunit_config.py
index 02ffc3a3e5dc..f1101075d458 100644
--- a/tools/testing/kunit/kunit_config.py
+++ b/tools/testing/kunit/kunit_config.py
@@ -40,15 +40,14 @@ class Kconfig(object):
self._entries.append(entry)
def is_subset_of(self, other: 'Kconfig') -> bool:
+ other_dict = {e.name: e.value for e in other.entries()}
for a in self.entries():
- found = False
- for b in other.entries():
- if a.name != b.name:
+ b = other_dict.get(a.name)
+ if b is None:
+ if a.value == 'n':
continue
- if a.value != b.value:
- return False
- found = True
- if a.value != 'n' and found == False:
+ return False
+ elif a.value != b:
return False
return True
base-commit: c6f7e1510b872c281ff603a3108c084b6548d35c
--
2.29.2.576.ga3fc446d84-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kunit: tool: simplify kconfig is_subset_of() logic
2020-12-08 23:21 [PATCH] kunit: tool: simplify kconfig is_subset_of() logic Daniel Latypov
@ 2020-12-09 7:28 ` David Gow
2021-02-05 22:28 ` Brendan Higgins
1 sibling, 0 replies; 3+ messages in thread
From: David Gow @ 2020-12-09 7:28 UTC (permalink / raw)
To: Daniel Latypov
Cc: Brendan Higgins, Linux Kernel Mailing List,
open list:KERNEL SELFTEST FRAMEWORK, Shuah Khan
On Wed, Dec 9, 2020 at 7:21 AM Daniel Latypov <dlatypov@google.com> wrote:
>
> Don't use an O(nm) algorithm* and make it more readable by using a dict.
>
> *Most obviously, it does a nested for-loop over the entire other config.
> A bit more subtle, it calls .entries(), which constructs a set from the
> list for _every_ outer iteration.
>
> Signed-off-by: Daniel Latypov <dlatypov@google.com>
> ---
Thanks! This works great here: I didn't time it to see how much faster
it is, but it's clearly an improvement.
Reviewed-by: David Gow <davidgow@google.com>
Cheers,
-- David
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kunit: tool: simplify kconfig is_subset_of() logic
2020-12-08 23:21 [PATCH] kunit: tool: simplify kconfig is_subset_of() logic Daniel Latypov
2020-12-09 7:28 ` David Gow
@ 2021-02-05 22:28 ` Brendan Higgins
1 sibling, 0 replies; 3+ messages in thread
From: Brendan Higgins @ 2021-02-05 22:28 UTC (permalink / raw)
To: Daniel Latypov
Cc: David Gow, Linux Kernel Mailing List,
open list:KERNEL SELFTEST FRAMEWORK, Shuah Khan
On Tue, Dec 8, 2020 at 3:21 PM Daniel Latypov <dlatypov@google.com> wrote:
>
> Don't use an O(nm) algorithm* and make it more readable by using a dict.
>
> *Most obviously, it does a nested for-loop over the entire other config.
> A bit more subtle, it calls .entries(), which constructs a set from the
> list for _every_ outer iteration.
>
> Signed-off-by: Daniel Latypov <dlatypov@google.com>
Tested-by: Brendan Higgins <brendanhiggins@google.com>
Acked-by: Brendan Higgins <brendanhiggins@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-06 3:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 23:21 [PATCH] kunit: tool: simplify kconfig is_subset_of() logic Daniel Latypov
2020-12-09 7:28 ` David Gow
2021-02-05 22:28 ` Brendan Higgins
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.