MCPcopy Create free account
hub / github.com/ActiveState/code / Main

Class Main

recipes/Python/578138_gprof2dotpy/recipe-578138.py:2745–2894  ·  view source on GitHub ↗

Main program.

Source from the content-addressed store, hash-verified

2743
2744
2745class Main:
2746 """Main program."""
2747
2748 themes = {
2749 "color": TEMPERATURE_COLORMAP,
2750 "pink": PINK_COLORMAP,
2751 "gray": GRAY_COLORMAP,
2752 "bw": BW_COLORMAP,
2753 }
2754
2755 def main(self):
2756 """Main program."""
2757
2758 parser = optparse.OptionParser(
2759 usage="\n\t%prog [options] [file] ...",
2760 version="%%prog %s" % __version__)
2761 parser.add_option(
2762 '-o', '--output', metavar='FILE',
2763 type="string", dest="output",
2764 help="output filename [stdout]")
2765 parser.add_option(
2766 '-n', '--node-thres', metavar='PERCENTAGE',
2767 type="float", dest="node_thres", default=0.5,
2768 help="eliminate nodes below this threshold [default: %default]")
2769 parser.add_option(
2770 '-e', '--edge-thres', metavar='PERCENTAGE',
2771 type="float", dest="edge_thres", default=0.1,
2772 help="eliminate edges below this threshold [default: %default]")
2773 parser.add_option(
2774 '-f', '--format',
2775 type="choice", choices=('prof', 'callgrind', 'perf', 'oprofile', 'hprof', 'sysprof', 'pstats', 'shark', 'sleepy', 'aqtime', 'xperf'),
2776 dest="format", default="prof",
2777 help="profile format: prof, callgrind, oprofile, hprof, sysprof, shark, sleepy, aqtime, pstats, or xperf [default: %default]")
2778 parser.add_option(
2779 '-c', '--colormap',
2780 type="choice", choices=('color', 'pink', 'gray', 'bw'),
2781 dest="theme", default="color",
2782 help="color map: color, pink, gray, or bw [default: %default]")
2783 parser.add_option(
2784 '-s', '--strip',
2785 action="store_true",
2786 dest="strip", default=False,
2787 help="strip function parameters, template parameters, and const modifiers from demangled C++ function names")
2788 parser.add_option(
2789 '-w', '--wrap',
2790 action="store_true",
2791 dest="wrap", default=False,
2792 help="wrap function names")
2793 # add a new option to control skew of the colorization curve
2794 parser.add_option(
2795 '--skew',
2796 type="float", dest="theme_skew", default=1.0,
2797 help="skew the colorization curve. Values < 1.0 give more variety to lower percentages. Value > 1.0 give less variety to lower percentages")
2798 (self.options, self.args) = parser.parse_args(sys.argv[1:])
2799
2800 if len(self.args) > 1 and self.options.format != 'pstats':
2801 parser.error('incorrect number of arguments')
2802

Callers 1

recipe-578138.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected