2008-11-13 21:52:03 +03:00
|
|
|
# perf.py - performance test routines
|
2009-06-21 18:45:47 +04:00
|
|
|
'''helper extension to measure performance'''
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2013-06-13 03:36:58 +04:00
|
|
|
from mercurial import cmdutil, scmutil, util, commands, obsolete
|
2013-04-05 07:36:46 +04:00
|
|
|
from mercurial import repoview, branchmap, merge, copies
|
2008-11-13 21:52:03 +03:00
|
|
|
import time, os, sys
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
import functools
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
formatteropts = commands.formatteropts
|
|
|
|
|
2013-01-04 22:20:51 +04:00
|
|
|
cmdtable = {}
|
|
|
|
command = cmdutil.command(cmdtable)
|
|
|
|
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
def gettimer(ui, opts=None):
|
|
|
|
"""return a timer function and formatter: (timer, formatter)
|
|
|
|
|
|
|
|
This functions exist to gather the creation of formatter in a single
|
|
|
|
place instead of duplicating it in all performance command."""
|
2015-01-11 06:13:10 +03:00
|
|
|
|
|
|
|
# enforce an idle period before execution to counteract power management
|
2015-07-18 22:16:36 +03:00
|
|
|
# experimental config: perf.presleep
|
2015-01-11 06:13:10 +03:00
|
|
|
time.sleep(ui.configint("perf", "presleep", 1))
|
|
|
|
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
if opts is None:
|
|
|
|
opts = {}
|
|
|
|
# redirect all to stderr
|
|
|
|
ui = ui.copy()
|
|
|
|
ui.fout = ui.ferr
|
|
|
|
# get a formatter
|
|
|
|
fm = ui.formatter('perf', opts)
|
|
|
|
return functools.partial(_timer, fm), fm
|
|
|
|
|
|
|
|
def _timer(fm, func, title=None):
|
2008-11-13 21:52:03 +03:00
|
|
|
results = []
|
|
|
|
begin = time.time()
|
|
|
|
count = 0
|
2011-06-01 14:38:46 +04:00
|
|
|
while True:
|
2008-11-13 21:52:03 +03:00
|
|
|
ostart = os.times()
|
|
|
|
cstart = time.time()
|
|
|
|
r = func()
|
|
|
|
cstop = time.time()
|
|
|
|
ostop = os.times()
|
|
|
|
count += 1
|
|
|
|
a, b = ostart, ostop
|
|
|
|
results.append((cstop - cstart, b[0] - a[0], b[1]-a[1]))
|
|
|
|
if cstop - begin > 3 and count >= 100:
|
|
|
|
break
|
|
|
|
if cstop - begin > 10 and count >= 3:
|
|
|
|
break
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
|
|
|
|
fm.startitem()
|
|
|
|
|
2009-11-11 19:02:00 +03:00
|
|
|
if title:
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.write('title', '! %s\n', title)
|
2008-11-13 21:52:03 +03:00
|
|
|
if r:
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.write('result', '! result: %s\n', r)
|
2008-11-13 21:52:03 +03:00
|
|
|
m = min(results)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.plain('!')
|
|
|
|
fm.write('wall', ' wall %f', m[0])
|
|
|
|
fm.write('comb', ' comb %f', m[1] + m[2])
|
|
|
|
fm.write('user', ' user %f', m[1])
|
|
|
|
fm.write('sys', ' sys %f', m[2])
|
|
|
|
fm.write('count', ' (best of %d)', count)
|
|
|
|
fm.plain('\n')
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfwalk', formatteropts)
|
|
|
|
def perfwalk(ui, repo, *pats, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2008-11-13 21:52:03 +03:00
|
|
|
try:
|
2011-06-19 01:52:51 +04:00
|
|
|
m = scmutil.match(repo[None], pats, {})
|
2010-01-01 02:19:30 +03:00
|
|
|
timer(lambda: len(list(repo.dirstate.walk(m, [], True, False))))
|
2012-05-12 18:02:46 +04:00
|
|
|
except Exception:
|
2008-11-13 21:52:03 +03:00
|
|
|
try:
|
2011-06-19 01:52:51 +04:00
|
|
|
m = scmutil.match(repo[None], pats, {})
|
2010-01-25 09:05:27 +03:00
|
|
|
timer(lambda: len([b for a, b, c in repo.dirstate.statwalk([], m)]))
|
2012-05-12 18:02:46 +04:00
|
|
|
except Exception:
|
2008-11-13 21:52:03 +03:00
|
|
|
timer(lambda: len(list(cmdutil.walk(repo, pats, {}))))
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfannotate', formatteropts)
|
|
|
|
def perfannotate(ui, repo, f, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2013-05-31 06:29:03 +04:00
|
|
|
fc = repo['.'][f]
|
|
|
|
timer(lambda: len(fc.annotate(True)))
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2013-05-31 06:29:03 +04:00
|
|
|
|
2013-01-04 22:20:51 +04:00
|
|
|
@command('perfstatus',
|
|
|
|
[('u', 'unknown', False,
|
2015-06-10 01:18:47 +03:00
|
|
|
'ask status to look for unknown files')] + formatteropts)
|
2012-12-04 01:53:53 +04:00
|
|
|
def perfstatus(ui, repo, **opts):
|
2008-11-13 21:52:03 +03:00
|
|
|
#m = match.always(repo.root, repo.getcwd())
|
2012-05-12 17:54:54 +04:00
|
|
|
#timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False,
|
|
|
|
# False))))
|
2015-11-20 00:02:27 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2015-06-10 01:18:47 +03:00
|
|
|
timer(lambda: sum(map(len, repo.status(unknown=opts['unknown']))))
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfaddremove', formatteropts)
|
|
|
|
def perfaddremove(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2013-04-02 10:09:36 +04:00
|
|
|
try:
|
|
|
|
oldquiet = repo.ui.quiet
|
|
|
|
repo.ui.quiet = True
|
2014-11-10 03:57:02 +03:00
|
|
|
matcher = scmutil.match(repo[None])
|
2014-11-25 06:27:49 +03:00
|
|
|
timer(lambda: scmutil.addremove(repo, matcher, "", dry_run=True))
|
2013-04-02 10:09:36 +04:00
|
|
|
finally:
|
|
|
|
repo.ui.quiet = oldquiet
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2013-04-02 10:09:36 +04:00
|
|
|
|
2012-05-20 06:44:23 +04:00
|
|
|
def clearcaches(cl):
|
|
|
|
# behave somewhat consistently across internal API changes
|
|
|
|
if util.safehasattr(cl, 'clearcaches'):
|
|
|
|
cl.clearcaches()
|
|
|
|
elif util.safehasattr(cl, '_nodecache'):
|
|
|
|
from mercurial.node import nullid, nullrev
|
|
|
|
cl._nodecache = {nullid: nullrev}
|
|
|
|
cl._nodepos = None
|
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfheads', formatteropts)
|
|
|
|
def perfheads(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-05-20 06:44:23 +04:00
|
|
|
cl = repo.changelog
|
|
|
|
def d():
|
|
|
|
len(cl.headrevs())
|
|
|
|
clearcaches(cl)
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perftags', formatteropts)
|
|
|
|
def perftags(ui, repo, **opts):
|
2013-09-20 18:14:59 +04:00
|
|
|
import mercurial.changelog
|
|
|
|
import mercurial.manifest
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2008-11-13 21:52:03 +03:00
|
|
|
def t():
|
2015-01-11 02:25:54 +03:00
|
|
|
repo.changelog = mercurial.changelog.changelog(repo.svfs)
|
|
|
|
repo.manifest = mercurial.manifest.manifest(repo.svfs)
|
2009-07-16 18:39:41 +04:00
|
|
|
repo._tags = None
|
2008-11-13 21:52:03 +03:00
|
|
|
return len(repo.tags())
|
|
|
|
timer(t)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfancestors', formatteropts)
|
|
|
|
def perfancestors(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-05-15 21:44:17 +04:00
|
|
|
heads = repo.changelog.headrevs()
|
|
|
|
def d():
|
2012-06-01 23:37:18 +04:00
|
|
|
for a in repo.changelog.ancestors(heads):
|
2012-05-15 21:44:17 +04:00
|
|
|
pass
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2012-05-15 21:44:17 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfancestorset', formatteropts)
|
|
|
|
def perfancestorset(ui, repo, revset, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-12-14 22:23:18 +04:00
|
|
|
revs = repo.revs(revset)
|
|
|
|
heads = repo.changelog.headrevs()
|
|
|
|
def d():
|
2012-12-19 00:47:20 +04:00
|
|
|
s = repo.changelog.ancestors(heads)
|
2012-12-14 22:23:18 +04:00
|
|
|
for rev in revs:
|
|
|
|
rev in s
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2012-12-14 22:23:18 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfdirs', formatteropts)
|
|
|
|
def perfdirs(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2013-04-02 00:46:32 +04:00
|
|
|
dirstate = repo.dirstate
|
|
|
|
'a' in dirstate
|
|
|
|
def d():
|
|
|
|
dirstate.dirs()
|
|
|
|
del dirstate._dirs
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2013-04-02 00:46:32 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfdirstate', formatteropts)
|
|
|
|
def perfdirstate(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2008-11-13 21:52:03 +03:00
|
|
|
"a" in repo.dirstate
|
|
|
|
def d():
|
|
|
|
repo.dirstate.invalidate()
|
|
|
|
"a" in repo.dirstate
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfdirstatedirs', formatteropts)
|
|
|
|
def perfdirstatedirs(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2008-11-13 21:52:03 +03:00
|
|
|
"a" in repo.dirstate
|
|
|
|
def d():
|
|
|
|
"a" in repo.dirstate._dirs
|
|
|
|
del repo.dirstate._dirs
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfdirstatefoldmap', formatteropts)
|
2015-11-24 23:08:21 +03:00
|
|
|
def perfdirstatefoldmap(ui, repo, **opts):
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2014-10-04 06:58:26 +04:00
|
|
|
dirstate = repo.dirstate
|
|
|
|
'a' in dirstate
|
|
|
|
def d():
|
2015-04-03 05:13:50 +03:00
|
|
|
dirstate._filefoldmap.get('a')
|
|
|
|
del dirstate._filefoldmap
|
|
|
|
timer(d)
|
|
|
|
fm.end()
|
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfdirfoldmap', formatteropts)
|
|
|
|
def perfdirfoldmap(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2015-04-03 05:13:50 +03:00
|
|
|
dirstate = repo.dirstate
|
|
|
|
'a' in dirstate
|
|
|
|
def d():
|
|
|
|
dirstate._dirfoldmap.get('a')
|
|
|
|
del dirstate._dirfoldmap
|
2014-10-04 06:58:26 +04:00
|
|
|
del dirstate._dirs
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2014-10-04 06:58:26 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfdirstatewrite', formatteropts)
|
|
|
|
def perfdirstatewrite(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-05-17 00:45:46 +04:00
|
|
|
ds = repo.dirstate
|
|
|
|
"a" in ds
|
|
|
|
def d():
|
|
|
|
ds._dirty = True
|
2015-10-16 19:15:34 +03:00
|
|
|
ds.write(repo.currenttransaction())
|
2012-05-17 00:45:46 +04:00
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2012-05-17 00:45:46 +04:00
|
|
|
|
2013-03-25 04:06:10 +04:00
|
|
|
@command('perfmergecalculate',
|
2015-06-10 01:18:47 +03:00
|
|
|
[('r', 'rev', '.', 'rev to merge against')] + formatteropts)
|
|
|
|
def perfmergecalculate(ui, repo, rev, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2013-03-25 04:06:10 +04:00
|
|
|
wctx = repo[None]
|
|
|
|
rctx = scmutil.revsingle(repo, rev, rev)
|
|
|
|
ancestor = wctx.ancestor(rctx)
|
|
|
|
# we don't want working dir files to be stat'd in the benchmark, so prime
|
|
|
|
# that cache
|
|
|
|
wctx.dirty()
|
|
|
|
def d():
|
|
|
|
# acceptremote is True because we don't want prompts in the middle of
|
|
|
|
# our benchmark
|
|
|
|
merge.calculateupdates(repo, wctx, rctx, ancestor, False, False, False,
|
|
|
|
acceptremote=True)
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2013-03-25 04:06:10 +04:00
|
|
|
|
2013-04-05 07:36:46 +04:00
|
|
|
@command('perfpathcopies', [], "REV REV")
|
2015-06-10 01:18:47 +03:00
|
|
|
def perfpathcopies(ui, repo, rev1, rev2, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2013-04-05 07:36:46 +04:00
|
|
|
ctx1 = scmutil.revsingle(repo, rev1, rev1)
|
|
|
|
ctx2 = scmutil.revsingle(repo, rev2, rev2)
|
|
|
|
def d():
|
|
|
|
copies.pathcopies(ctx1, ctx2)
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2013-04-05 07:36:46 +04:00
|
|
|
|
2013-09-07 00:35:29 +04:00
|
|
|
@command('perfmanifest', [], 'REV')
|
2015-06-10 01:18:47 +03:00
|
|
|
def perfmanifest(ui, repo, rev, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2013-09-07 00:35:29 +04:00
|
|
|
ctx = scmutil.revsingle(repo, rev, rev)
|
|
|
|
t = ctx.manifestnode()
|
2008-11-13 21:52:03 +03:00
|
|
|
def d():
|
2013-09-07 00:20:07 +04:00
|
|
|
repo.manifest._mancache.clear()
|
2008-11-13 21:52:03 +03:00
|
|
|
repo.manifest._cache = None
|
2013-09-07 00:20:07 +04:00
|
|
|
repo.manifest.read(t)
|
2008-11-13 21:52:03 +03:00
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfchangeset', formatteropts)
|
|
|
|
def perfchangeset(ui, repo, rev, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-03-16 00:58:55 +04:00
|
|
|
n = repo[rev].node()
|
|
|
|
def d():
|
2013-07-01 22:48:56 +04:00
|
|
|
repo.changelog.read(n)
|
2012-03-17 04:58:47 +04:00
|
|
|
#repo.changelog._cache = None
|
2012-03-16 00:58:55 +04:00
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2012-03-16 00:58:55 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfindex', formatteropts)
|
|
|
|
def perfindex(ui, repo, **opts):
|
2011-01-12 02:01:14 +03:00
|
|
|
import mercurial.revlog
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2011-01-19 00:55:49 +03:00
|
|
|
mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
|
2011-01-12 02:01:04 +03:00
|
|
|
n = repo["tip"].node()
|
2008-11-13 21:52:03 +03:00
|
|
|
def d():
|
2015-01-11 02:25:54 +03:00
|
|
|
cl = mercurial.revlog.revlog(repo.svfs, "00changelog.i")
|
2012-03-15 22:11:03 +04:00
|
|
|
cl.rev(n)
|
2008-11-13 21:52:03 +03:00
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfstartup', formatteropts)
|
|
|
|
def perfstartup(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2008-11-13 21:52:03 +03:00
|
|
|
cmd = sys.argv[0]
|
|
|
|
def d():
|
|
|
|
os.system("HGRCPATH= %s version -q > /dev/null" % cmd)
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfparents', formatteropts)
|
|
|
|
def perfparents(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2008-11-13 21:52:03 +03:00
|
|
|
nl = [repo.changelog.node(i) for i in xrange(1000)]
|
|
|
|
def d():
|
|
|
|
for n in nl:
|
|
|
|
repo.changelog.parents(n)
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfctxfiles', formatteropts)
|
2015-11-24 23:08:21 +03:00
|
|
|
def perfctxfiles(ui, repo, x, **opts):
|
2015-03-18 20:03:44 +03:00
|
|
|
x = int(x)
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2015-03-18 20:03:44 +03:00
|
|
|
def d():
|
|
|
|
len(repo[x].files())
|
|
|
|
timer(d)
|
|
|
|
fm.end()
|
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfrawfiles', formatteropts)
|
2015-11-24 23:08:21 +03:00
|
|
|
def perfrawfiles(ui, repo, x, **opts):
|
2015-03-18 20:03:44 +03:00
|
|
|
x = int(x)
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2015-03-18 20:03:44 +03:00
|
|
|
cl = repo.changelog
|
|
|
|
def d():
|
|
|
|
len(cl.read(x)[3])
|
|
|
|
timer(d)
|
|
|
|
fm.end()
|
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perflookup', formatteropts)
|
|
|
|
def perflookup(ui, repo, rev, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2008-11-13 21:52:03 +03:00
|
|
|
timer(lambda: len(repo.lookup(rev)))
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2008-11-13 21:52:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfrevrange', formatteropts)
|
|
|
|
def perfrevrange(ui, repo, *specs, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-06-02 02:50:22 +04:00
|
|
|
revrange = scmutil.revrange
|
|
|
|
timer(lambda: len(revrange(repo, specs)))
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2012-06-02 02:50:22 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfnodelookup', formatteropts)
|
|
|
|
def perfnodelookup(ui, repo, rev, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-04-13 01:05:59 +04:00
|
|
|
import mercurial.revlog
|
|
|
|
mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
|
|
|
|
n = repo[rev].node()
|
2015-01-11 02:25:54 +03:00
|
|
|
cl = mercurial.revlog.revlog(repo.svfs, "00changelog.i")
|
2012-04-13 01:05:59 +04:00
|
|
|
def d():
|
|
|
|
cl.rev(n)
|
2012-05-20 06:44:23 +04:00
|
|
|
clearcaches(cl)
|
2012-04-13 01:05:59 +04:00
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2012-04-13 01:05:59 +04:00
|
|
|
|
2013-01-04 22:20:51 +04:00
|
|
|
@command('perflog',
|
2015-06-10 01:18:47 +03:00
|
|
|
[('', 'rename', False, 'ask log to follow renames')] + formatteropts)
|
2009-11-25 01:02:02 +03:00
|
|
|
def perflog(ui, repo, **opts):
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2009-03-23 15:12:03 +03:00
|
|
|
ui.pushbuffer()
|
2009-11-25 01:02:02 +03:00
|
|
|
timer(lambda: commands.log(ui, repo, rev=[], date='', user='',
|
|
|
|
copies=opts.get('rename')))
|
2009-03-23 15:12:03 +03:00
|
|
|
ui.popbuffer()
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2009-03-23 15:12:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfmoonwalk', formatteropts)
|
|
|
|
def perfmoonwalk(ui, repo, **opts):
|
2013-11-18 03:04:28 +04:00
|
|
|
"""benchmark walking the changelog backwards
|
|
|
|
|
|
|
|
This also loads the changelog data for each revision in the changelog.
|
|
|
|
"""
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2013-11-18 03:04:28 +04:00
|
|
|
def moonwalk():
|
|
|
|
for i in xrange(len(repo), -1, -1):
|
|
|
|
ctx = repo[i]
|
|
|
|
ctx.branch() # read changelog data (in addition to the index)
|
|
|
|
timer(moonwalk)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2013-11-18 03:04:28 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perftemplating', formatteropts)
|
|
|
|
def perftemplating(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2009-03-23 15:12:03 +03:00
|
|
|
ui.pushbuffer()
|
|
|
|
timer(lambda: commands.log(ui, repo, rev=[], date='', user='',
|
|
|
|
template='{date|shortdate} [{rev}:{node|short}]'
|
|
|
|
' {author|person}: {desc|firstline}\n'))
|
|
|
|
ui.popbuffer()
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2009-03-23 15:12:03 +03:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfcca', formatteropts)
|
|
|
|
def perfcca(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-07-18 18:51:20 +04:00
|
|
|
timer(lambda: scmutil.casecollisionauditor(ui, False, repo.dirstate))
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2012-04-10 21:07:16 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perffncacheload', formatteropts)
|
|
|
|
def perffncacheload(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-10-12 21:43:24 +04:00
|
|
|
s = repo.store
|
2012-04-13 02:21:52 +04:00
|
|
|
def d():
|
|
|
|
s.fncache._load()
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2012-04-13 02:21:52 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perffncachewrite', formatteropts)
|
|
|
|
def perffncachewrite(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-10-12 21:43:24 +04:00
|
|
|
s = repo.store
|
2012-04-13 02:21:52 +04:00
|
|
|
s.fncache._load()
|
2015-11-25 01:01:11 +03:00
|
|
|
lock = repo.lock()
|
|
|
|
tr = repo.transaction('perffncachewrite')
|
2012-04-13 02:21:52 +04:00
|
|
|
def d():
|
|
|
|
s.fncache._dirty = True
|
2015-11-25 01:01:11 +03:00
|
|
|
s.fncache.write(tr)
|
2012-04-13 02:21:52 +04:00
|
|
|
timer(d)
|
2015-11-25 01:01:11 +03:00
|
|
|
lock.release()
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2012-04-13 02:21:52 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perffncacheencode', formatteropts)
|
|
|
|
def perffncacheencode(ui, repo, **opts):
|
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-10-12 21:43:24 +04:00
|
|
|
s = repo.store
|
2012-09-14 15:02:31 +04:00
|
|
|
s.fncache._load()
|
|
|
|
def d():
|
|
|
|
for p in s.fncache.entries:
|
|
|
|
s.encode(p)
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2012-09-14 15:02:31 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfdiffwd', formatteropts)
|
|
|
|
def perfdiffwd(ui, repo, **opts):
|
2009-11-11 19:02:00 +03:00
|
|
|
"""Profile diff of working directory changes"""
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2009-11-11 19:02:00 +03:00
|
|
|
options = {
|
|
|
|
'w': 'ignore_all_space',
|
|
|
|
'b': 'ignore_space_change',
|
|
|
|
'B': 'ignore_blank_lines',
|
|
|
|
}
|
|
|
|
|
|
|
|
for diffopt in ('', 'w', 'b', 'B', 'wB'):
|
|
|
|
opts = dict((options[c], '1') for c in diffopt)
|
|
|
|
def d():
|
|
|
|
ui.pushbuffer()
|
|
|
|
commands.diff(ui, repo, **opts)
|
|
|
|
ui.popbuffer()
|
|
|
|
title = 'diffopts: %s' % (diffopt and ('-' + diffopt) or 'none')
|
|
|
|
timer(d, title)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2009-11-11 19:02:00 +03:00
|
|
|
|
2013-01-04 22:20:51 +04:00
|
|
|
@command('perfrevlog',
|
2015-06-10 01:18:47 +03:00
|
|
|
[('d', 'dist', 100, 'distance between the revisions')] + formatteropts,
|
2013-01-04 22:20:51 +04:00
|
|
|
"[INDEXFILE]")
|
2010-07-27 19:20:09 +04:00
|
|
|
def perfrevlog(ui, repo, file_, **opts):
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2010-07-27 19:20:09 +04:00
|
|
|
from mercurial import revlog
|
|
|
|
dist = opts['dist']
|
|
|
|
def d():
|
|
|
|
r = revlog.revlog(lambda fn: open(fn, 'rb'), file_)
|
|
|
|
for x in xrange(0, len(r), dist):
|
|
|
|
r.revision(r.node(x))
|
|
|
|
|
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2010-07-27 19:20:09 +04:00
|
|
|
|
2013-01-04 22:22:40 +04:00
|
|
|
@command('perfrevset',
|
2015-11-22 02:39:18 +03:00
|
|
|
[('C', 'clear', False, 'clear volatile cache between each call.'),
|
|
|
|
('', 'contexts', False, 'obtain changectx for each revision')]
|
2015-06-10 01:18:47 +03:00
|
|
|
+ formatteropts, "REVSET")
|
2015-11-22 02:39:18 +03:00
|
|
|
def perfrevset(ui, repo, expr, clear=False, contexts=False, **opts):
|
2013-01-04 22:22:40 +04:00
|
|
|
"""benchmark the execution time of a revset
|
|
|
|
|
2013-02-10 21:24:29 +04:00
|
|
|
Use the --clean option if need to evaluate the impact of build volatile
|
2013-01-04 22:22:40 +04:00
|
|
|
revisions set cache on the revset execution. Volatile cache hold filtered
|
|
|
|
and obsolete related cache."""
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2012-12-06 23:21:11 +04:00
|
|
|
def d():
|
2013-01-04 22:22:40 +04:00
|
|
|
if clear:
|
|
|
|
repo.invalidatevolatilesets()
|
2015-11-22 02:39:18 +03:00
|
|
|
if contexts:
|
|
|
|
for ctx in repo.set(expr): pass
|
|
|
|
else:
|
|
|
|
for r in repo.revs(expr): pass
|
2012-12-06 23:21:11 +04:00
|
|
|
timer(d)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2013-01-04 22:23:26 +04:00
|
|
|
|
2015-06-10 01:18:47 +03:00
|
|
|
@command('perfvolatilesets', formatteropts)
|
|
|
|
def perfvolatilesets(ui, repo, *names, **opts):
|
2013-01-04 22:23:26 +04:00
|
|
|
"""benchmark the computation of various volatile set
|
|
|
|
|
|
|
|
Volatile set computes element related to filtering and obsolescence."""
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2013-01-04 22:23:26 +04:00
|
|
|
repo = repo.unfiltered()
|
|
|
|
|
|
|
|
def getobs(name):
|
|
|
|
def d():
|
|
|
|
repo.invalidatevolatilesets()
|
|
|
|
obsolete.getrevs(repo, name)
|
|
|
|
return d
|
|
|
|
|
2013-01-04 22:24:32 +04:00
|
|
|
allobs = sorted(obsolete.cachefuncs)
|
|
|
|
if names:
|
|
|
|
allobs = [n for n in allobs if n in names]
|
|
|
|
|
|
|
|
for name in allobs:
|
2013-01-04 22:23:26 +04:00
|
|
|
timer(getobs(name), title=name)
|
|
|
|
|
|
|
|
def getfiltered(name):
|
|
|
|
def d():
|
|
|
|
repo.invalidatevolatilesets()
|
2013-12-24 04:04:51 +04:00
|
|
|
repoview.filterrevs(repo, name)
|
2013-01-04 22:23:26 +04:00
|
|
|
return d
|
|
|
|
|
2013-01-04 22:24:32 +04:00
|
|
|
allfilter = sorted(repoview.filtertable)
|
|
|
|
if names:
|
|
|
|
allfilter = [n for n in allfilter if n in names]
|
|
|
|
|
|
|
|
for name in allfilter:
|
2013-01-04 22:23:26 +04:00
|
|
|
timer(getfiltered(name), title=name)
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2013-01-11 21:39:43 +04:00
|
|
|
|
|
|
|
@command('perfbranchmap',
|
|
|
|
[('f', 'full', False,
|
|
|
|
'Includes build time of subset'),
|
2015-06-10 01:18:47 +03:00
|
|
|
] + formatteropts)
|
|
|
|
def perfbranchmap(ui, repo, full=False, **opts):
|
2013-01-11 21:39:43 +04:00
|
|
|
"""benchmark the update of a branchmap
|
|
|
|
|
|
|
|
This benchmarks the full repo.branchmap() call with read and write disabled
|
|
|
|
"""
|
2015-06-10 01:18:47 +03:00
|
|
|
timer, fm = gettimer(ui, opts)
|
2013-01-11 21:39:43 +04:00
|
|
|
def getbranchmap(filtername):
|
|
|
|
"""generate a benchmark function for the filtername"""
|
|
|
|
if filtername is None:
|
|
|
|
view = repo
|
|
|
|
else:
|
|
|
|
view = repo.filtered(filtername)
|
|
|
|
def d():
|
|
|
|
if full:
|
|
|
|
view._branchcaches.clear()
|
|
|
|
else:
|
|
|
|
view._branchcaches.pop(filtername, None)
|
|
|
|
view.branchmap()
|
|
|
|
return d
|
|
|
|
# add filter in smaller subset to bigger subset
|
|
|
|
possiblefilters = set(repoview.filtertable)
|
|
|
|
allfilters = []
|
|
|
|
while possiblefilters:
|
|
|
|
for name in possiblefilters:
|
2013-11-06 23:38:34 +04:00
|
|
|
subset = branchmap.subsettable.get(name)
|
2013-01-11 21:39:43 +04:00
|
|
|
if subset not in possiblefilters:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
assert False, 'subset cycle %s!' % possiblefilters
|
|
|
|
allfilters.append(name)
|
|
|
|
possiblefilters.remove(name)
|
|
|
|
|
|
|
|
# warm the cache
|
|
|
|
if not full:
|
|
|
|
for name in allfilters:
|
|
|
|
repo.filtered(name).branchmap()
|
|
|
|
# add unfiltered
|
|
|
|
allfilters.append(None)
|
|
|
|
oldread = branchmap.read
|
|
|
|
oldwrite = branchmap.branchcache.write
|
|
|
|
try:
|
|
|
|
branchmap.read = lambda repo: None
|
|
|
|
branchmap.write = lambda repo: None
|
|
|
|
for name in allfilters:
|
|
|
|
timer(getbranchmap(name), title=str(name))
|
|
|
|
finally:
|
|
|
|
branchmap.read = oldread
|
|
|
|
branchmap.branchcache.write = oldwrite
|
perf: use a formatter for output
We use a `formatter` object in the perf extensions. This allow the use of
formatted output like json. To avoid adding logic to create a formatter and pass
it around to the timer function in every command, we add a `gettimer` function
in charge of returning a `timer` function as simple as before but embedding an
appropriate formatter.
This new `gettimer` function also return the formatter as it needs to be
explicitly closed at the end of the command.
example output:
$ hg --config ui.formatjson=True perfvolatilesets visible obsolete
[
{
"comb": 0.02,
"count": 126,
"sys": 0.0,
"title": "obsolete",
"user": 0.02,
"wall": 0.0199398994446
},
{
"comb": 0.02,
"count": 117,
"sys": 0.0,
"title": "visible",
"user": 0.02,
"wall": 0.0250301361084
}
]
2014-11-04 13:40:06 +03:00
|
|
|
fm.end()
|
2014-11-21 03:27:55 +03:00
|
|
|
|
|
|
|
@command('perfloadmarkers')
|
|
|
|
def perfloadmarkers(ui, repo):
|
|
|
|
"""benchmark the time to parse the on-disk markers for a repo
|
|
|
|
|
|
|
|
Result is the number of markers in the repo."""
|
|
|
|
timer, fm = gettimer(ui)
|
2015-01-11 02:25:54 +03:00
|
|
|
timer(lambda: len(obsolete.obsstore(repo.svfs)))
|
2014-11-21 03:27:55 +03:00
|
|
|
fm.end()
|