1034 * -10: + :10 |
1034 * -10: + :10 |
1035 * :10: + -10: |
1035 * :10: + -10: |
1036 * -10000: |
1036 * -10000: |
1037 * -10000: + 0 |
1037 * -10000: + 0 |
1038 |
1038 |
1039 It is not currently possible to check for lookup of a missing node.""" |
1039 It is not currently possible to check for lookup of a missing node. For |
|
1040 deeper lookup benchmarking, checkout the `perfnodemap` command.""" |
1040 import mercurial.revlog |
1041 import mercurial.revlog |
1041 opts = _byteskwargs(opts) |
1042 opts = _byteskwargs(opts) |
1042 timer, fm = gettimer(ui, opts) |
1043 timer, fm = gettimer(ui, opts) |
1043 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
1044 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
1044 if opts[b'no_lookup']: |
1045 if opts[b'no_lookup']: |
1061 clearchangelog(unfi) |
1062 clearchangelog(unfi) |
1062 def d(): |
1063 def d(): |
1063 cl = makecl(unfi) |
1064 cl = makecl(unfi) |
1064 for n in nodes: |
1065 for n in nodes: |
1065 cl.rev(n) |
1066 cl.rev(n) |
|
1067 timer(d, setup=setup) |
|
1068 fm.end() |
|
1069 |
|
1070 @command(b'perfnodemap', [ |
|
1071 (b'', b'rev', [], b'revision to be looked up (default tip)'), |
|
1072 ] + formatteropts) |
|
1073 def perfnodemap(ui, repo, **opts): |
|
1074 """benchmark the time necessary to look up revision from a cold nodemap |
|
1075 |
|
1076 Depending on the implementation, the amount and order of revision we look |
|
1077 up can varies. Example of useful set to test: |
|
1078 * tip |
|
1079 * 0 |
|
1080 * -10: |
|
1081 * :10 |
|
1082 * -10: + :10 |
|
1083 * :10: + -10: |
|
1084 * -10000: |
|
1085 * -10000: + 0 |
|
1086 |
|
1087 The command currently focus on valid binary lookup. Benchmarking for |
|
1088 hexlookup, prefix lookup and missing lookup would also be valuable. |
|
1089 """ |
|
1090 import mercurial.revlog |
|
1091 opts = _byteskwargs(opts) |
|
1092 timer, fm = gettimer(ui, opts) |
|
1093 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
|
1094 |
|
1095 unfi = repo.unfiltered() |
|
1096 # find the filecache func directly |
|
1097 # This avoid polluting the benchmark with the filecache logic |
|
1098 makecl = unfi.__class__.changelog.func |
|
1099 if not opts[b'rev']: |
|
1100 raise error.Abort('use --rev to specify revisions to look up') |
|
1101 revs = scmutil.revrange(repo, opts[b'rev']) |
|
1102 cl = repo.changelog |
|
1103 nodes = [cl.node(r) for r in revs] |
|
1104 |
|
1105 # use a list to pass reference to a nodemap from one closure to the next |
|
1106 nodeget = [None] |
|
1107 def setnodeget(): |
|
1108 # probably not necessary, but for good measure |
|
1109 clearchangelog(unfi) |
|
1110 nodeget[0] = makecl(unfi).nodemap.get |
|
1111 |
|
1112 def setup(): |
|
1113 setnodeget() |
|
1114 def d(): |
|
1115 get = nodeget[0] |
|
1116 for n in nodes: |
|
1117 get(n) |
|
1118 |
1066 timer(d, setup=setup) |
1119 timer(d, setup=setup) |
1067 fm.end() |
1120 fm.end() |
1068 |
1121 |
1069 @command(b'perfstartup', formatteropts) |
1122 @command(b'perfstartup', formatteropts) |
1070 def perfstartup(ui, repo, **opts): |
1123 def perfstartup(ui, repo, **opts): |