##// END OF EJS Templates
py3: make statprof's chrome output work...
Martin von Zweigbergk -
r43105:cde1c101 default
parent child Browse files
Show More
@@ -759,7 +759,7 b' def simplifypath(path):'
759
759
760 if path in _pathcache:
760 if path in _pathcache:
761 return _pathcache[path]
761 return _pathcache[path]
762 hgpath = pycompat.fsencode(encoding.__file__).rsplit(os.sep, 2)[0]
762 hgpath = encoding.__file__.rsplit(os.sep, 2)[0]
763 for p in [hgpath] + sys.path:
763 for p in [hgpath] + sys.path:
764 prefix = p + os.sep
764 prefix = p + os.sep
765 if path.startswith(prefix):
765 if path.startswith(prefix):
@@ -807,7 +807,7 b' def write_to_chrome(data, fp, minthresho'
807 parent = stackid(stack[1:])
807 parent = stackid(stack[1:])
808 myid = len(stack2id)
808 myid = len(stack2id)
809 stack2id[stack] = myid
809 stack2id[stack] = myid
810 id2stack.append(dict(category=stack[0][0], name='%s %s' % stack[0]))
810 id2stack.append(dict(category=stack[0][0], name=r'%s %s' % stack[0]))
811 if parent is not None:
811 if parent is not None:
812 id2stack[-1].update(parent=parent)
812 id2stack[-1].update(parent=parent)
813 return myid
813 return myid
@@ -842,7 +842,7 b' def write_to_chrome(data, fp, minthresho'
842 if minthreshold <= duration <= maxthreshold:
842 if minthreshold <= duration <= maxthreshold:
843 # ensure no zero-duration events
843 # ensure no zero-duration events
844 sampletime = max(oldtime + clamp, sample.time)
844 sampletime = max(oldtime + clamp, sample.time)
845 samples.append(dict(ph='E', name=oldfunc, cat=oldcat, sf=oldsid,
845 samples.append(dict(ph=r'E', name=oldfunc, cat=oldcat, sf=oldsid,
846 ts=sampletime*1e6, pid=0))
846 ts=sampletime*1e6, pid=0))
847 else:
847 else:
848 blacklist.add(oldidx)
848 blacklist.add(oldidx)
@@ -851,8 +851,10 b' def write_to_chrome(data, fp, minthresho'
851 # events given only stack snapshots.
851 # events given only stack snapshots.
852
852
853 for sample in data.samples:
853 for sample in data.samples:
854 stack = tuple((('%s:%d' % (simplifypath(frame.path), frame.lineno),
854 stack = tuple(((r'%s:%d' % (simplifypath(pycompat.sysstr(frame.path)),
855 frame.function) for frame in sample.stack))
855 frame.lineno),
856 pycompat.sysstr(frame.function))
857 for frame in sample.stack))
856 qstack = collections.deque(stack)
858 qstack = collections.deque(stack)
857 if laststack == qstack:
859 if laststack == qstack:
858 continue
860 continue
@@ -866,8 +868,8 b' def write_to_chrome(data, fp, minthresho'
866 laststack.appendleft(f)
868 laststack.appendleft(f)
867 path, name = f
869 path, name = f
868 sid = stackid(tuple(laststack))
870 sid = stackid(tuple(laststack))
869 samples.append(dict(ph='B', name=name, cat=path, ts=sample.time*1e6,
871 samples.append(dict(ph=r'B', name=name, cat=path,
870 sf=sid, pid=0))
872 ts=sample.time*1e6, sf=sid, pid=0))
871 laststack = collections.deque(stack)
873 laststack = collections.deque(stack)
872 while laststack:
874 while laststack:
873 poplast()
875 poplast()
General Comments 0
You need to be logged in to leave comments. Login now