diff --git a/benchmarks/others.py b/benchmarks/others.py index 0d3697261693560d857ac34c8e066f9298fd53cf_YmVuY2htYXJrcy9vdGhlcnMucHk=..128fb0cdef1ce83a87d036be6e8cbe3cf8c6f4c5_YmVuY2htYXJrcy9vdGhlcnMucHk= 100644 --- a/benchmarks/others.py +++ b/benchmarks/others.py @@ -1,4 +1,7 @@ -from .utils import BaseTestSuite +import os +import os.path + +from .utils import BaseTestSuite, params_as_kwargs class PerfTestSuite(BaseTestSuite): @@ -9,9 +12,6 @@ def track_status(self, *args, **kwargs): return self.perfext("perfstatus") - def track_manifest(self, *args, **kwargs): - return self.perfext("perfmanifest", "tip") - def track_heads(self, *args, **kwargs): return self.perfext("perfheads") @@ -53,3 +53,46 @@ def track_perfwalk(self, *args, **kwargs): return self.perfext("perfwalk") + + +class ManifestPerfTestSuite(BaseTestSuite): + params = BaseTestSuite.params + [['persist', 'clear']] + param_names = BaseTestSuite.param_names + ['disk_cache'] + + _manifestcache = os.path.join('.hg', 'cache', 'manifestfulltextcache') + _manifestcache_backup = _manifestcache + '.asv_backup' + + @params_as_kwargs + def setup(self, disk_cache, **kwargs): + super(ManifestPerfTestSuite, self).setup(**kwargs) + # back up manifest cache state + self.cache_path = os.path.join(self.repo_path, self._manifestcache) + self.cache_present = os.path.exists(self.cache_path) + if self.cache_present: + self.backup_path = os.path.join( + self.repo_path, self._manifestcache_backup) + if os.path.exists(self.backup_path): + # in case a previous run left one behind + os.remove(self.backup_path) + os.link(self.cache_path, self.backup_path) + # ensure we have a current cache + self.hg('debugupdatecaches') + + @params_as_kwargs + def teardown(self, **kwargs): + super(ManifestPerfTestSuite, self).teardown(**kwargs) + if self.cache_present: + # restore manifest cache + os.remove(self.cache_path) + os.rename(self.backup_path, self.cache_path) + elif os.path.exists(self.cache_path): + # remove manifest cache, it wasn't there before + os.remove(self.cache_path) + + @params_as_kwargs + def track_manifest(self, disk_cache, **kwargs): + command = ("perfmanifest", "tip") + if disk_cache == 'clear': + command += '--clear-disk', + return self.perfext(*command) +