[PATCH] ignore log to stdout in benchmarks

Robert Collins robertc at robertcollins.net
Tue Aug 15 05:42:41 BST 2006


On Tue, 2006-08-08 at 15:42 +0200, Jan Balster wrote:
> To reduce the memory footprint of the benchmark tests I wrote a patch to throw 
> the log output away. This and the related patch "[merge] remove some more 
> mutters" reduced the memory consumption of the benchmark suite benchmarks from 
> 1.1 GB to ~120 MB (the suite contains the bundle benchmarks we are working on).
> 
> The attached diff overwrites the _finishLogFile method of the Benchmark class in 
> bzrlib/benchmarks/__init__.py.
> 
> Cheers,
>   Jan
> plain text document attachment (diff.txt)
> === modified file 'bzrlib/benchmarks/__init__.py'
> --- bzrlib/benchmarks/__init__.py       2006-07-19 05:54:36 +0000
> +++ bzrlib/benchmarks/__init__.py       2006-08-08 13:24:50 +0000
> @@ -20,10 +20,22 @@
>  from bzrlib import bzrdir, plugin
>  from bzrlib.tests.TestUtil import TestLoader
>  from bzrlib.tests.blackbox import ExternalBase
> +import bzrlib.trace
> +import os
> 
> 
>  class Benchmark(ExternalBase):
> 
> +    def _finishLogFile(self):
> +        if self._log_file is None:
> +            return
> +        bzrlib.trace.disable_test_log(self._log_nonce)
> +        self._log_contents = 'DELETED to lower the memory footprint'
> +        self._log_file.close()
> +        os.remove(self._log_file_name)
> +        self._log_file = self._log_file_name = None
> +
> +

Is there any reason this should not be done to bzrlib.tests.TestCase ?

That is
 - change the default test case finishLogFile to delete the in memory
copy.
 - Add a method 'getLogFileContents()' which will read the log file from
disk.
 - Add a method 'setKeepLogFile()' which if called tells finishLogFile
to unlink the file from disk rather than just closing it.

I think this would be a bit cleaner and generally more useful - it would
reduce memory footprint during regular bzr selftest too.

-Rob

-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060815/904ee340/attachment.pgp 


More information about the bazaar mailing list