Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hackaton 2024][Rhodium-Antimoine][PYTHON] Avoid List Comprehension In Iterations #113

Open
AntoineMeheut opened this issue May 30, 2024 · 0 comments
Assignees
Labels
checkers Hackathon 2024 New issues tagged during the hackathon 2024

Comments

@AntoineMeheut
Copy link
Contributor

AntoineMeheut commented May 30, 2024

[PYTHON] Avoid List Comprehension In Iterations

Associated rule link

https://github.com/green-code-initiative/ecoCode/blob/main/ecocode-rules-specifications/src/main/rules/EC404/python/EC404.asciidoc

Language and platform

Example: Python
Itel proc 12th Gen Core i7-1255U 1,7 GHz
Docker container : python:3.9-slim
memory = 4go
swap = 6go
cpu=2

Measure justification

Profiling with psutil directly in code
Reading RAM and CPU used
Completion of 100,000,000 cycles to amplify impacts

Application of the formula for calculating the CO2 equivalent present on this url: https://boavizta.org/blog/empreinte-de-la-fabrication-d-un-serveur
servermanufgwp(kgCO2eq) = servertypegwp(kgCO2eq) + cpuunits(unit) x cpubasegwp(kgCO2eq/unit) + ramsize(GB) x ramsizegwp(kgCO2eq/GB)

Calculating the differential between code implementing bad code and code implementing good code practice

Validation

The rule is validated by the measurement.
Link to the code used to validate the rule: https://github.com/JulienPlanque/python-profiling
Validation result
Launching the container for the AvoidListComprehensionInIterationsBad.py script...
4493365500.0
Launching the container for the AvoidListComprehensionInIterationsGood.py script...
4478423217.0
Calculation of deltas:
Delta between bad practice and good code practice for rule AvoidListComprehensionInIterations: 14942283

@AntoineMeheut AntoineMeheut added checkers Hackathon 2024 New issues tagged during the hackathon 2024 labels May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checkers Hackathon 2024 New issues tagged during the hackathon 2024
Projects
None yet
Development

No branches or pull requests

2 participants