This repository investigates the energy consumption and performance of coding solutions generated by large language models (LLMs). It provides a systematic approach to measuring and analyzing the computational costs of solutions written in Python, C++, and Java, including both baseline solutions (human-written) and those generated by three LLMs (ChatGPT 4o, OpenAI o1-mini and GitHub Copilot).
LeetCodeBenchmark.xlsx: Contains the benchmark problems used in the study.Tasks_and_Tags.xlsx: Lists all problems and their associated tags.Prompt_Structure.png: A visual representation of the prompt setup used to instruct the LLMs.Grouping_of_Tags.xlsx: Groups tags into broader categories of programming tasks.
data/: Stores baseline and LLM-generated solutions.- Four subfolders:
baseline/: Baseline coding solutions written by humans and taken from LeetCode.4o/,o1-mini/,github/: Solutions generated by LLMs.
- Each subfolder organizes solutions by problem, with separate files for Python, C++, and Java implementations.
- Four subfolders:
measurements_perf/: Measurements obtained usingperfon Linux.measurements_powermetrics/: Measurements obtained usingpowermetricson macOS.- Other Files: Scripts for measuring execution time of solutions in
data/and outputting results to themeasurements_perf/andmeasurements_powermetrics/folders.
- Subfolders for each language (
C++,Java,Python) containing:- Folders for
perfandpowermetricsresults. Each folder includes:- Per-problem subfolders with execution time and energy consumption graphs comparing the baseline and LLM-generated solutions.
- Files (
resultsC.json,resultsJava.json,resultsPython.json) aggregating all results in JSON format.
- Folders for
- Jupyter Notebooks:
Save_All_Results_*.ipynb: Processes raw measurement data and saves results to theResultsfolder.- Other notebooks for:
- Correlation analysis.
- Generating heatmaps (stored in
Heatmap/). - Creating graphs categorized by tags or problems (stored in
Graphs_tags/andGraphs_problems/).
- Use the scripts in
srcto measure execution time and energy consumption:- For Linux: Measurements with
perfare saved insrc/measurements_perf. - For macOS: Measurements with
powermetricsare saved insrc/measurements_powermetrics.
- For Linux: Measurements with
Run the Save_All_Results_*.ipynb notebooks in the Analysis folder to save processed data to the Results folder.
Use the analysis notebooks in Analysis to:
- Explore correlations between energy consumption and performance metrics.
- Visualize data with heatmaps and other graphs.
- Per-problem graphs comparing execution time and energy consumption for baseline and LLM-generated solutions.
- Aggregated results for Python, C++, and Java in the
Resultsfolder.
This project is licensed under the MIT License.