{
    "content": [
        {
            "type": "text",
            "text": "# profile (pydoc)\n\n**Summary:** profile - Class for profiling Python code.\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **MODULE REFERENCE** (8 lines)\n- **CLASSES** (3 lines) — 1 subsections\n  - class Profile (103 lines)\n- **FUNCTIONS** (1 lines) — 2 subsections\n  - run (10 lines)\n  - runctx (5 lines)\n- **DATA** (2 lines)\n- **FILE** (3 lines)\n\n## Full Content\n\n### NAME\n\nprofile - Class for profiling Python code.\n\n### MODULE REFERENCE\n\nhttps://docs.python.org/3.10/library/profile.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n\n### CLASSES\n\nbuiltins.object\nProfile\n\n#### class Profile\n\n|  Profile(timer=None, bias=None)\n|\n|  Profiler class.\n|\n|  self.cur is always a tuple.  Each such tuple corresponds to a stack\n|  frame that is currently active (self.cur[-2]).  The following are the\n|  definitions of its members.  We use this external \"parallel stack\" to\n|  avoid contaminating the program that we are profiling. (old profiler\n|  used to write into the frames local dictionary!!) Derived classes\n|  can change the definition of some entries, as long as they leave\n|  [-2:] intact (frame and previous tuple).  In case an internal error is\n|  detected, the -3 element is used as the function name.\n|\n|  [ 0] = Time that needs to be charged to the parent frame's function.\n|         It is used so that a function call will not have to access the\n|         timing data for the parent frame.\n|  [ 1] = Total time spent in this frame's function, excluding time in\n|         subfunctions (this latter is tallied in cur[2]).\n|  [ 2] = Total time spent in subfunctions, excluding time executing the\n|         frame's function (this latter is tallied in cur[1]).\n|  [-3] = Name of the function that corresponds to this frame.\n|  [-2] = Actual frame that we correspond to (used to sync exception handling).\n|  [-1] = Our parent 6-tuple (corresponds to frame.fback).\n|\n|  Timing data for each function is stored as a 5-tuple in the dictionary\n|  self.timings[].  The index is always the name stored in self.cur[-3].\n|  The following are the definitions of the members:\n|\n|  [0] = The number of times this function was called, not counting direct\n|        or indirect recursion,\n|  [1] = Number of times this function appears on the stack, minus one\n|  [2] = Total time spent internal to this function\n|  [3] = Cumulative time that this function was present on the stack.  In\n|        non-recursive functions, this is the total execution time from start\n|        to finish of each invocation of a function, including time spent in\n|        all subfunctions.\n|  [4] = A dictionary indicating for each function name, the number of times\n|        it was called by us.\n|\n|  Methods defined here:\n|\n|  init(self, timer=None, bias=None)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  calibrate(self, m, verbose=0)\n|\n|  createstats(self)\n|\n|  dumpstats(self, file)\n|\n|  printstats(self, sort=-1)\n|\n|  run(self, cmd)\n|\n|  runcall(self, func, /, *args, kw)\n|      # This method is more useful to profile a single function call.\n|\n|  runctx(self, cmd, globals, locals)\n|\n|  setcmd(self, cmd)\n|\n|  simulatecall(self, name)\n|\n|  simulatecmdcomplete(self)\n|\n|  snapshotstats(self)\n|\n|  tracedispatch(self, frame, event, arg)\n|\n|  tracedispatchccall(self, frame, t)\n|\n|  tracedispatchcall(self, frame, t)\n|\n|  tracedispatchexception(self, frame, t)\n|\n|  tracedispatchi(self, frame, event, arg)\n|\n|  tracedispatchl(self, frame, event, arg)\n|\n|  tracedispatchmac(self, frame, event, arg)\n|\n|  tracedispatchreturn(self, frame, t)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  bias = 0\n|\n|  dispatch = {'ccall': <function Profile.tracedispatchccall>, 'cexc...\n|\n|  fakecode = <class 'profile.Profile.fakecode'>\n|\n|  fakeframe = <class 'profile.Profile.fakeframe'>\n\n### FUNCTIONS\n\n#### run\n\nRun statement under profiler optionally saving results in filename\n\nThis function takes a single argument that can be passed to the\n\"exec\" statement, and an optional file name.  In all cases this\nroutine attempts to \"exec\" its first argument and gather profiling\nstatistics from the execution. If no file name is present, then this\nfunction automatically prints a simple profiling report, sorted by the\nstandard name string (file/line/function-name) that is presented in\neach line.\n\n#### runctx\n\nRun statement under profiler, supplying your own globals and locals,\noptionally saving results in filename.\n\nstatement and filename have the same semantics as profile.run\n\n### DATA\n\nall = ['run', 'runctx', 'Profile']\n\n### FILE\n\n/usr/lib/python3.10/profile.py\n\n"
        }
    ],
    "structuredContent": {
        "command": "profile",
        "section": "",
        "mode": "pydoc",
        "summary": "profile - Class for profiling Python code.",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "MODULE REFERENCE",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "CLASSES",
                "lines": 3,
                "subsections": [
                    {
                        "name": "class Profile",
                        "lines": 103
                    }
                ]
            },
            {
                "name": "FUNCTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "run",
                        "lines": 10
                    },
                    {
                        "name": "runctx",
                        "lines": 5
                    }
                ]
            },
            {
                "name": "DATA",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "FILE",
                "lines": 3,
                "subsections": []
            }
        ]
    }
}