77import time
88import math
99import logging
10+ import itertools
1011
1112from collections import defaultdict
1213from argparse import ArgumentParser , ArgumentError , REMAINDER , RawTextHelpFormatter
@@ -492,6 +493,15 @@ def flame_plotter(filename, index=0, timestamps=True, children=True, options=Non
492493 mem = mem [ind ]
493494 t = t [ind ]
494495 stack_size = 1 + max (ex [4 ] for executions in ts .values () for ex in executions )
496+ def level_to_saturation (level ):
497+ return 1 - 0.75 * level / stack_size
498+
499+ colors = [
500+ itertools .cycle ([
501+ pl .matplotlib .colors .hsv_to_rgb ((0 , level_to_saturation (level ), 1 )),
502+ pl .matplotlib .colors .hsv_to_rgb ((0.1 , level_to_saturation (level ), 1 )),
503+ ]) for level in range (stack_size )
504+ ]
495505
496506 # Plot curves
497507 global_start = float (t [0 ])
@@ -500,7 +510,7 @@ def flame_plotter(filename, index=0, timestamps=True, children=True, options=Non
500510 max_mem = mem .max ()
501511 max_mem_ind = mem .argmax ()
502512
503- cmap = pl .cm .get_cmap ('gist_rainbow' )
513+ # cmap = pl.cm.get_cmap('gist_rainbow')
504514 mem_line_colors = ("k" , "b" , "r" , "g" , "c" , "y" , "m" )
505515 mem_line_label = time .strftime ("%d / %m / %Y - start at %H:%M:%S" ,
506516 time .localtime (global_start )) \
@@ -547,7 +557,7 @@ def flame_plotter(filename, index=0, timestamps=True, children=True, options=Non
547557 x0 , x1 = execution [:2 ]
548558 y0 = execution [4 ]
549559 y1 = y0 + 1
550- color = cmap ( 0.5 )
560+ color = next ( colors [ y0 ] )
551561 add_timestamp_rectangle (
552562 timestamp_ax ,
553563 x0 , x1 , y0 , y1 ,
0 commit comments