contrib/perf.py
changeset 41439 7eb7637e34bf
parent 41438 e9891c734bf8
child 41469 c9ff93889550
equal deleted inserted replaced
41438:e9891c734bf8 41439:7eb7637e34bf
  1012 
  1012 
  1013     timer(runone, setup=setupone, title=b"load")
  1013     timer(runone, setup=setupone, title=b"load")
  1014     fm.end()
  1014     fm.end()
  1015 
  1015 
  1016 @command(b'perfindex', [
  1016 @command(b'perfindex', [
  1017             (b'', b'rev', b'', b'revision to be looked up (default tip)'),
  1017             (b'', b'rev', [], b'revision to be looked up (default tip)'),
  1018             (b'', b'no-lookup', None, b'do not revision lookup post creation'),
  1018             (b'', b'no-lookup', None, b'do not revision lookup post creation'),
  1019          ] + formatteropts)
  1019          ] + formatteropts)
  1020 def perfindex(ui, repo, **opts):
  1020 def perfindex(ui, repo, **opts):
  1021     """benchmark index creation time followed by a lookup
  1021     """benchmark index creation time followed by a lookup
  1022 
  1022 
  1023     The default is to look `tip` up. Depending on the index implementation,
  1023     The default is to look `tip` up. Depending on the index implementation,
  1024     the revision looked up can matters. For example, an implementation
  1024     the revision looked up can matters. For example, an implementation
  1025     scanning the index will have a faster lookup time for `--rev tip` than for
  1025     scanning the index will have a faster lookup time for `--rev tip` than for
  1026     `--rev 0`.
  1026     `--rev 0`. The number of looked up revisions and their order can also
       
  1027     matters.
       
  1028 
       
  1029     Example of useful set to test:
       
  1030     * tip
       
  1031     * 0
       
  1032     * -10:
       
  1033     * :10
       
  1034     * -10: + :10
       
  1035     * :10: + -10:
       
  1036     * -10000:
       
  1037     * -10000: + 0
  1027 
  1038 
  1028     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."""
  1029     import mercurial.revlog
  1040     import mercurial.revlog
  1030     opts = _byteskwargs(opts)
  1041     opts = _byteskwargs(opts)
  1031     timer, fm = gettimer(ui, opts)
  1042     timer, fm = gettimer(ui, opts)
  1032     mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
  1043     mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
  1033     if opts[b'no_lookup']:
  1044     if opts[b'no_lookup']:
  1034         n = None
  1045         if opts['rev']:
  1035     elif opts[b'rev'] is None:
  1046             raise error.Abort('--no-lookup and --rev are mutually exclusive')
  1036         n = repo[b"tip"].node()
  1047         nodes = []
       
  1048     elif not opts[b'rev']:
       
  1049         nodes = [repo[b"tip"].node()]
  1037     else:
  1050     else:
  1038         rev = scmutil.revsingle(repo, opts[b'rev'])
  1051         revs = scmutil.revrange(repo, opts[b'rev'])
  1039         n = repo[rev].node()
  1052         cl = repo.changelog
       
  1053         nodes = [cl.node(r) for r in revs]
  1040 
  1054 
  1041     unfi = repo.unfiltered()
  1055     unfi = repo.unfiltered()
  1042     # find the filecache func directly
  1056     # find the filecache func directly
  1043     # This avoid polluting the benchmark with the filecache logic
  1057     # This avoid polluting the benchmark with the filecache logic
  1044     makecl = unfi.__class__.changelog.func
  1058     makecl = unfi.__class__.changelog.func
  1045     def setup():
  1059     def setup():
  1046         # probably not necessary, but for good measure
  1060         # probably not necessary, but for good measure
  1047         clearchangelog(unfi)
  1061         clearchangelog(unfi)
  1048     def d():
  1062     def d():
  1049         cl = makecl(unfi)
  1063         cl = makecl(unfi)
  1050         if n is not None:
  1064         for n in nodes:
  1051             cl.rev(n)
  1065             cl.rev(n)
  1052     timer(d, setup=setup)
  1066     timer(d, setup=setup)
  1053     fm.end()
  1067     fm.end()
  1054 
  1068 
  1055 @command(b'perfstartup', formatteropts)
  1069 @command(b'perfstartup', formatteropts)