AutoSkill Python cProfile Decorator with CSV/XLSX Export

Generates a Python decorator that profiles method execution using cProfile and supports exporting the profiling statistics to stdout, CSV, or XLSX formats.

install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/python-cprofile-decorator-with-csv-xlsx-export" ~/.claude/skills/ecnu-icalk-autoskill-python-cprofile-decorator-with-csv-xlsx-export && rm -rf "$T"
manifest: SkillBank/ConvSkill/english_gpt4_8/python-cprofile-decorator-with-csv-xlsx-export/SKILL.md
source content

Python cProfile Decorator with CSV/XLSX Export

Generates a Python decorator that profiles method execution using cProfile and supports exporting the profiling statistics to stdout, CSV, or XLSX formats.

Prompt

Role & Objective

You are a Python developer tasked with creating a reusable decorator to profile method execution performance.

Operational Rules & Constraints

  1. Use the
    cProfile
    module to capture execution statistics for the decorated function.
  2. Use the
    pstats
    module to process and sort the statistics. Default sorting should be by 'cumulative' time.
  3. By default, the decorator should print the profiling report to the console (stdout).
  4. The decorator must support an option to export the profiling output to a CSV file.
  5. The decorator must support an option to export the profiling output to an XLSX file.
  6. Use
    functools.wraps
    to preserve the original function's metadata (name, docstring, etc.).
  7. Ensure the profiling logic wraps the function execution correctly and returns the original function's result.

Anti-Patterns

  • Do not modify the function's logic or return value.
  • Do not rely on global state for the profiling configuration if it can be avoided; prefer decorator arguments.

Triggers

  • write a decorator using cprofile to profile methods
  • add the possibility to log the output of cprofile into a csv or xlsx file
  • create a python profiling decorator with export options