tests/test-profile.t
changeset 30316 faf1b8923da2
parent 30259 d06c049695e6
child 30317 3fd53cc1aad8
equal deleted inserted replaced
30315:0911191dc4c9 30316:faf1b8923da2
    45   $ grep CallCount ../profile.log | wc -l
    45   $ grep CallCount ../profile.log | wc -l
    46   \s*1 (re)
    46   \s*1 (re)
    47 
    47 
    48 #endif
    48 #endif
    49 
    49 
       
    50 Install an extension that can sleep and guarantee a profiler has time to run
       
    51 
       
    52   $ cat >> sleepext.py << EOF
       
    53   > import time
       
    54   > from mercurial import cmdutil, commands
       
    55   > cmdtable = {}
       
    56   > command = cmdutil.command(cmdtable)
       
    57   > @command('sleep', [], 'hg sleep')
       
    58   > def sleep(ui, *args, **kwargs):
       
    59   >     time.sleep(0.1)
       
    60   > EOF
       
    61 
       
    62   $ cat >> $HGRCPATH << EOF
       
    63   > [extensions]
       
    64   > sleep = `pwd`/sleepext.py
       
    65   > EOF
       
    66 
       
    67 statistical profiler works
       
    68 
       
    69   $ HGPROF=stat hg --profile sleep 2>../out
       
    70   $ grep Sample ../out
       
    71   Sample count: \d+ (re)
       
    72 
       
    73 Various statprof formatters work
       
    74 
       
    75   $ HGPROF=stat hg --profile --config profiling.statformat=byline sleep 2>../out
       
    76   $ head -n 1 ../out
       
    77     %   cumulative      self          
       
    78   $ grep Sample ../out
       
    79   Sample count: \d+ (re)
       
    80 
       
    81   $ HGPROF=stat hg --profile --config profiling.statformat=bymethod sleep 2>../out
       
    82   $ head -n 1 ../out
       
    83     %   cumulative      self          
       
    84   $ grep Sample ../out
       
    85   Sample count: \d+ (re)
       
    86 
       
    87   $ HGPROF=stat hg --profile --config profiling.statformat=hotpath sleep 2>../out
       
    88   $ grep Sample ../out
       
    89   Sample count: \d+ (re)
       
    90 
       
    91   $ HGPROF=stat hg --profile --config profiling.statformat=json sleep 2>../out
       
    92   $ cat ../out
       
    93   \[\[\d+.* (re)
       
    94 
    50   $ cd ..
    95   $ cd ..