Message ID | 1430338217-25518-2-git-send-email-s.martin49@gmail.com |
---|---|
State | Accepted |
Headers | show |
2015/4/30 Samuel Martin <s.martin49@gmail.com>: > Signed-off-by: Samuel Martin <s.martin49@gmail.com> > > --- > changes v1->v2 > - none > --- > scripts/autobuild-run | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/scripts/autobuild-run b/scripts/autobuild-run > index 6e83de9..01e3265 100755 > --- a/scripts/autobuild-run > +++ b/scripts/autobuild-run > @@ -655,12 +655,14 @@ def send_results(result, **kwargs): > > srcroot = os.path.join(outputdir, "build", '-'.join(reason)) > destroot = os.path.join(resultdir, '-'.join(reason)) > + config_files = ('config.log', 'CMakeCache.txt', 'CMakeError.log', > + 'CMakeOutput.log') > config_files = set(('config.log', ...)) It's negligible in terms of real time difference (<= 0.0d seconds), but for efficiency reasons, don't use a tuple or list when doing lookups ("fname in config_files"). os.walk() might return 100s or 1000s of file names in total, and for each fname, you have to through the entire list/tuple (until fname found or end of list, whatever comes first). Data structures like set/frozenset/dict perform lookups faster (on average). > for root, dirs, files in os.walk(srcroot): > dest = os.path.join(destroot, os.path.relpath(root, srcroot)) > > for fname in files: > - if fname == 'config.log': > + if fname in config_files: > if not os.path.exists(dest): > os.makedirs(dest) > shutil.copy(os.path.join(root, fname), os.path.join(dest, fname)) >
Dear Samuel Martin, On Wed, 29 Apr 2015 22:10:16 +0200, Samuel Martin wrote: > Signed-off-by: Samuel Martin <s.martin49@gmail.com> > > --- > changes v1->v2 > - none > --- > scripts/autobuild-run | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) Applied, thanks. Thomas
Dear André Erdmann, On Thu, 30 Apr 2015 00:54:54 +0200, André Erdmann wrote: > config_files = set(('config.log', ...)) > > It's negligible in terms of real time difference (<= 0.0d seconds), > but for efficiency reasons, don't use a tuple or list when doing > lookups ("fname in config_files"). > > os.walk() might return 100s or 1000s of file names in total, > and for each fname, you have to through the entire list/tuple > (until fname found or end of list, whatever comes first). > Data structures like set/frozenset/dict perform lookups faster (on average). Can you submit a follow-up patch implementing this suggestion? Thanks a lot! Thomas
diff --git a/scripts/autobuild-run b/scripts/autobuild-run index 6e83de9..01e3265 100755 --- a/scripts/autobuild-run +++ b/scripts/autobuild-run @@ -655,12 +655,14 @@ def send_results(result, **kwargs): srcroot = os.path.join(outputdir, "build", '-'.join(reason)) destroot = os.path.join(resultdir, '-'.join(reason)) + config_files = ('config.log', 'CMakeCache.txt', 'CMakeError.log', + 'CMakeOutput.log') for root, dirs, files in os.walk(srcroot): dest = os.path.join(destroot, os.path.relpath(root, srcroot)) for fname in files: - if fname == 'config.log': + if fname in config_files: if not os.path.exists(dest): os.makedirs(dest) shutil.copy(os.path.join(root, fname), os.path.join(dest, fname))
Signed-off-by: Samuel Martin <s.martin49@gmail.com> --- changes v1->v2 - none --- scripts/autobuild-run | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)