tests/test-chg.t
changeset 47023 a2bf93ab3014
parent 47022 ec081d7f0009
child 47024 8fcc0a829f3d
equal deleted inserted replaced
47022:ec081d7f0009 47023:a2bf93ab3014
   466   $ LANG= LC_ALL= LC_CTYPE= chg \
   466   $ LANG= LC_ALL= LC_CTYPE= chg \
   467   >    --config extensions.debugenv=$TESTTMP/debugenv.py debugenv
   467   >    --config extensions.debugenv=$TESTTMP/debugenv.py debugenv
   468   LC_ALL=
   468   LC_ALL=
   469   LC_CTYPE=
   469   LC_CTYPE=
   470   LANG=
   470   LANG=
       
   471 
       
   472 Profiling isn't permanently enabled or carried over between chg invocations that
       
   473 share the same server
       
   474   $ cp $HGRCPATH.orig $HGRCPATH
       
   475   $ hg init $TESTTMP/profiling
       
   476   $ cd $TESTTMP/profiling
       
   477   $ filteredchg() {
       
   478   >   CHGDEBUG=1 chg "$@" 2>&1 | egrep 'Sample count|start cmdserver' || true
       
   479   > }
       
   480   $ newchg() {
       
   481   >   chg --kill-chg-daemon
       
   482   >   filteredchg "$@" | egrep -v 'start cmdserver' || true
       
   483   > }
       
   484 (--profile isn't permanently on just because it was specified when chg was
       
   485 started)
       
   486   $ newchg log -r . --profile
       
   487   Sample count: * (glob)
       
   488   $ filteredchg log -r .
       
   489 (enabling profiling via config works, even on the first chg command that starts
       
   490 a cmdserver)
       
   491   $ cat >> $HGRCPATH <<EOF
       
   492   > [profiling]
       
   493   > type=stat
       
   494   > enabled=1
       
   495   > EOF
       
   496   $ newchg log -r .
       
   497   Sample count: * (glob)
       
   498   $ filteredchg log -r .
       
   499   Sample count: * (glob)
       
   500 (test that we aren't accumulating more and more samples each run)
       
   501   $ cat > $TESTTMP/debugsleep.py <<EOF
       
   502   > import time
       
   503   > from mercurial import registrar
       
   504   > cmdtable = {}
       
   505   > command = registrar.command(cmdtable)
       
   506   > @command(b'debugsleep', [], b'', norepo=True)
       
   507   > def debugsleep(ui):
       
   508   >   start = time.time()
       
   509   >   x = 0
       
   510   >   while time.time() < start + 0.5:
       
   511   >     time.sleep(.1)
       
   512   >     x += 1
       
   513   >   ui.status(b'%d debugsleep iterations in %.03fs\n' % (x, time.time() - start))
       
   514   > EOF
       
   515   $ cat >> $HGRCPATH <<EOF
       
   516   > [extensions]
       
   517   > debugsleep = $TESTTMP/debugsleep.py
       
   518   > EOF
       
   519   $ newchg debugsleep > run_1
       
   520   $ filteredchg debugsleep > run_2
       
   521   $ filteredchg debugsleep > run_3
       
   522   $ filteredchg debugsleep > run_4
       
   523 FIXME: Run 4 should not be >3x Run 1's number of samples.
       
   524   $ "$PYTHON" <<EOF
       
   525   > r1 = int(open("run_1", "r").read().split()[-1])
       
   526   > r4 = int(open("run_4", "r").read().split()[-1])
       
   527   > print("Run 1: %d samples\nRun 4: %d samples\nRun 4 > 3 * Run 1: %s" %
       
   528   >       (r1, r4, r4 > (r1 * 3)))
       
   529   > EOF
       
   530   Run 1: * samples (glob)
       
   531   Run 4: * samples (glob)
       
   532   Run 4 > 3 * Run 1: True
       
   533 (Disabling with --no-profile on the commandline still works, but isn't permanent)
       
   534   $ newchg log -r . --no-profile
       
   535   $ filteredchg log -r .
       
   536   Sample count: * (glob)
       
   537   $ filteredchg log -r . --no-profile
       
   538   $ filteredchg log -r .
       
   539   Sample count: * (glob)