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.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill python-cprofile-decorator-with-csv-xlsx-exportAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.0 KB, 303 tokens by cl100k_base, as published. Nobody here has run it
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
cProfilemodule to capture execution statistics for the decorated function. - Use the
pstatsmodule to process and sort the statistics. Default sorting should be by 'cumulative' time. - 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
functools.wrapsto preserve the original function's metadata (name, docstring, etc.). - 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
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.