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.mdsource 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
- Use the
module to capture execution statistics for the decorated function.cProfile - Use the
module to process and sort the statistics. Default sorting should be by 'cumulative' time.pstats - By default, the decorator should print the profiling report to the console (stdout).
- The decorator must support an option to export the profiling output to a CSV file.
- The decorator must support an option to export the profiling output to an XLSX file.
- Use
to preserve the original function's metadata (name, docstring, etc.).functools.wraps - 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