Skip to content
Snippets Groups Projects
Commit 128fb0cd authored by Martijn Pieters's avatar Martijn Pieters
Browse files

perfext: add clear disk cache case and back up existing cache first

parent 0d369726
No related branches found
No related tags found
No related merge requests found
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment