Re: [PATCH STABLE] statprof: sort by time percentage as a secondary key

2018-10-24 Thread Yuya Nishihara
On Tue, 23 Oct 2018 23:37:20 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison 
> # Date 1540351037 14400
> #  Tue Oct 23 23:17:17 2018 -0400
> # Branch stable
> # Node ID 3662c0ac3ab4b256ecabb348cc91605ee8973abb
> # Parent  49c7b701fdc2a8659b6f752aef507764d40ed5d0
> statprof: sort by time percentage as a secondary key
> 
> On Windows, os.times() only returns user and system times.  Real elapsed time 
> is
> 0.  That results in no actual times reported, an end wall time of 0.00, 
> and
> seemingly randomly sorted stack frames.  This at least provides test stability
> in test-profile.t.

Sounds like we should change the default back to 'cpu' globally, or at least
on Windows.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH STABLE] statprof: sort by time percentage as a secondary key

2018-10-23 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1540351037 14400
#  Tue Oct 23 23:17:17 2018 -0400
# Branch stable
# Node ID 3662c0ac3ab4b256ecabb348cc91605ee8973abb
# Parent  49c7b701fdc2a8659b6f752aef507764d40ed5d0
statprof: sort by time percentage as a secondary key

On Windows, os.times() only returns user and system times.  Real elapsed time is
0.  That results in no actual times reported, an end wall time of 0.00, and
seemingly randomly sorted stack frames.  This at least provides test stability
in test-profile.t.

diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -501,7 +501,10 @@ def display_by_line(data, fp):
 '''Print the profiler data with each sample line represented
 as one row in a table.  Sorted by self-time per line.'''
 stats = SiteStats.buildstats(data.samples)
-stats.sort(reverse=True, key=lambda x: x.selfseconds())
+
+# Windows doesn't collect selfseconds, and everything is 0.  So break the
+# tie and use selfpercent for test stability.
+stats.sort(reverse=True, key=lambda x: (x.selfseconds(), x.selfpercent()))
 
 fp.write(b'%5.5s %10.10s   %7.7s  %-8.8s\n' % (
 b'%  ', b'cumulative', b'self', b''))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel