##// END OF EJS Templates
perf: make `hg perfwrite` more flexible...
Manuel Jacob -
r45530:c2df0bca default
parent child Browse files
Show More
@@ -3794,19 +3794,47 b' def perflrucache('
3794 fm.end()
3794 fm.end()
3795
3795
3796
3796
3797 @command(b'perfwrite', formatteropts)
3797 @command(
3798 b'perfwrite',
3799 formatteropts
3800 + [
3801 (b'', b'write-method', b'write', b'ui write method'),
3802 (b'', b'nlines', 100, b'number of lines'),
3803 (b'', b'nitems', 100, b'number of items (per line)'),
3804 (b'', b'item', b'x', b'item that is written'),
3805 (b'', b'batch-line', None, b'pass whole line to write method at once'),
3806 (b'', b'flush-line', None, b'flush after each line'),
3807 ],
3808 )
3798 def perfwrite(ui, repo, **opts):
3809 def perfwrite(ui, repo, **opts):
3799 """microbenchmark ui.write
3810 """microbenchmark ui.write (and others)
3800 """
3811 """
3801 opts = _byteskwargs(opts)
3812 opts = _byteskwargs(opts)
3802
3813
3814 write = getattr(ui, _sysstr(opts[b'write_method']))
3815 nlines = int(opts[b'nlines'])
3816 nitems = int(opts[b'nitems'])
3817 item = opts[b'item']
3818 batch_line = opts.get(b'batch_line')
3819 flush_line = opts.get(b'flush_line')
3820
3821 if batch_line:
3822 line = item * nitems + b'\n'
3823
3824 def benchmark():
3825 for i in pycompat.xrange(nlines):
3826 if batch_line:
3827 write(line)
3828 else:
3829 for i in pycompat.xrange(nitems):
3830 write(item)
3831 write(b'\n')
3832 if flush_line:
3833 ui.flush()
3834 ui.flush()
3835
3803 timer, fm = gettimer(ui, opts)
3836 timer, fm = gettimer(ui, opts)
3804
3837 timer(benchmark)
3805 def write():
3806 for i in range(100000):
3807 ui.writenoi18n(b'Testing write performance\n')
3808
3809 timer(write)
3810 fm.end()
3838 fm.end()
3811
3839
3812
3840
@@ -17,6 +17,10 b''
17 was compiled against a OpenSSL version supporting TLS 1.1 or TLS 1.2
17 was compiled against a OpenSSL version supporting TLS 1.1 or TLS 1.2
18 (likely this requires the OpenSSL version to be at least 1.0.1).
18 (likely this requires the OpenSSL version to be at least 1.0.1).
19
19
20 * The `hg perfwrite` command from contrib/perf.py was made more flexible and
21 changed its default behavior. To get the previous behavior, run `hg perfwrite
22 --nlines=100000 --nitems=1 --item='Testing write performance' --batch-line`.
23
20
24
21 == Internal API Changes ==
25 == Internal API Changes ==
22
26
@@ -180,7 +180,7 b' perfstatus'
180 perfvolatilesets
180 perfvolatilesets
181 benchmark the computation of various volatile set
181 benchmark the computation of various volatile set
182 perfwalk (no help text available)
182 perfwalk (no help text available)
183 perfwrite microbenchmark ui.write
183 perfwrite microbenchmark ui.write (and others)
184
184
185 (use 'hg help -v perf' to show built-in aliases and global options)
185 (use 'hg help -v perf' to show built-in aliases and global options)
186 $ hg perfaddremove
186 $ hg perfaddremove
General Comments 0
You need to be logged in to leave comments. Login now