Mercurial > hg
annotate tests/test-hg-parseurl.py @ 20836:a8b4541bb961
grep: reuse the first "util.binary()" result for efficiency
Before this patch, to check whether the file in the specified revision
is binary or not, "util.binary()" is invoked via internal function
"binary()" of "hg grep" once per a line of "hg grep" output, even
though binary-ness is not changed in the same file.
This patch reuses the first "util.binary()" invocation result by
annotating internal function "binary()" with "@util.cachefunc".
Performance improvement measured by "hgperf grep -r 88d8e568add1 vfs
mercurial/scmutil.py":
before this patch:
! wall 0.024000 comb 0.015600 user 0.015600 sys 0.000000 (best of 118)
after this patch:
! wall 0.023000 comb 0.015600 user 0.015600 sys 0.000000 (best of 123)
Status of recent(88d8e568add1) "mercurial/scmutil.py":
# of lines: 919 (may affect cost of search)
# of bytes: 29633 (may affect cost of "util.binary()")
# of matches: 22 (may affect frequency of "util.binary()")
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 15 Feb 2014 19:52:36 +0900 |
parents | 375872fdadba |
children | 8a23f88131c3 |
rev | line source |
---|---|
8174
29bc5d18714a
hg: allow hg.parseurl(url, None)
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
1 from mercurial.hg import parseurl |
29bc5d18714a
hg: allow hg.parseurl(url, None)
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
2 |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
8174
diff
changeset
|
3 def testparse(url, branch=[]): |
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
8174
diff
changeset
|
4 print '%s, branches: %r' % parseurl(url, branch) |
8174
29bc5d18714a
hg: allow hg.parseurl(url, None)
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
5 |
29bc5d18714a
hg: allow hg.parseurl(url, None)
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
6 testparse('http://example.com/no/anchor') |
29bc5d18714a
hg: allow hg.parseurl(url, None)
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
7 testparse('http://example.com/an/anchor#foo') |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
8174
diff
changeset
|
8 testparse('http://example.com/no/anchor/branches', branch=['foo']) |
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
8174
diff
changeset
|
9 testparse('http://example.com/an/anchor/branches#bar', branch=['foo']) |
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
8174
diff
changeset
|
10 testparse('http://example.com/an/anchor/branches-None#foo', branch=None) |
13897
375872fdadba
hg: make parseurl() consistently return normalised path
Thomas Arendsen Hein <thomas@intevation.de>
parents:
12865
diff
changeset
|
11 testparse('http://example.com/') |
375872fdadba
hg: make parseurl() consistently return normalised path
Thomas Arendsen Hein <thomas@intevation.de>
parents:
12865
diff
changeset
|
12 testparse('http://example.com') |
375872fdadba
hg: make parseurl() consistently return normalised path
Thomas Arendsen Hein <thomas@intevation.de>
parents:
12865
diff
changeset
|
13 testparse('http://example.com#foo') |