tests/test-profile.t
changeset 47563 dc3f7aa15423
parent 47562 17fde6763286
child 48876 42d2b31cee0b
equal deleted inserted replaced
47562:17fde6763286 47563:dc3f7aa15423
    71   > from mercurial import registrar
    71   > from mercurial import registrar
    72   > cmdtable = {}
    72   > cmdtable = {}
    73   > command = registrar.command(cmdtable)
    73   > command = registrar.command(cmdtable)
    74   > @command(b'sleep', [], b'hg sleep')
    74   > @command(b'sleep', [], b'hg sleep')
    75   > def sleep_for_at_least_one_stat_cycle(ui, *args, **kwargs):
    75   > def sleep_for_at_least_one_stat_cycle(ui, *args, **kwargs):
    76   >     time.sleep(0.1)
    76   >     t = time.time()  # don't use time.sleep because we need CPU time
       
    77   >     while time.time() - t < 0.5:
       
    78   >         pass
    77   > EOF
    79   > EOF
    78 
    80 
    79   $ cat >> $HGRCPATH << EOF
    81   $ cat >> $HGRCPATH << EOF
    80   > [extensions]
    82   > [extensions]
    81   > sleep = `pwd`/sleepext_with_a_long_filename.py
    83   > sleep = `pwd`/sleepext_with_a_long_filename.py
    98   $ hg --profile --config profiling.statformat=bymethod sleep 2>../out || cat ../out
   100   $ hg --profile --config profiling.statformat=bymethod sleep 2>../out || cat ../out
    99   $ head -n 1 ../out
   101   $ head -n 1 ../out
   100     %   cumulative      self          
   102     %   cumulative      self          
   101   $ cat ../out | statprofran
   103   $ cat ../out | statprofran
   102 
   104 
   103   $ hg --profile --config profiling.statformat=hotpath sleep 2>../out || cat ../out
   105 Windows real time tracking is broken, only use CPU
       
   106 
       
   107 #if no-windows
       
   108   $ hg --profile --config profiling.time-track=real --config profiling.statformat=hotpath sleep 2>../out || cat ../out
   104   $ cat ../out | statprofran
   109   $ cat ../out | statprofran
   105   $ grep sleepext_with_a_long_filename.py ../out
   110   $ grep sleepext_with_a_long_filename.py ../out | head -n 1
   106   .* [0-9.]+%  [0-9.]+s  sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line 7:    time\.sleep.* (re)
   111   .* [0-9.]+%  [0-9.]+s  sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line \d+:\s+(while|pass).* (re)
       
   112 #endif
       
   113 
       
   114   $ hg --profile --config profiling.time-track=cpu --config profiling.statformat=hotpath sleep 2>../out || cat ../out
       
   115   $ cat ../out | statprofran
       
   116   $ grep sleepext_with_a_long_filename.py ../out | head -n 1
       
   117   .* [0-9.]+%  [0-9.]+s  sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line \d+:\s+(while|pass).* (re)
   107 
   118 
   108   $ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out
   119   $ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out
   109   $ cat ../out
   120   $ cat ../out
   110   \[\[-?\d+.* (re)
   121   \[\[-?\d+.* (re)
   111 
   122