green-code-initiative / ecoCode-challenge

Emboard in the hackhatons serie for improving ecoCode
4 stars 5 forks source link

[Hackaton 2024][Rhodium-Antimoine][PYTHON] Avoid Double Quote Check #115

Open AntoineMeheut opened 5 months ago

AntoineMeheut commented 5 months ago

Associated rule title

[PYTHON] Avoid Double Quote Check

Associated rule link

https://github.com/green-code-initiative/ecoCode/blob/main/ecocode-rules-specifications/src/main/rules/EC66/python/EC66.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 50 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 not really validated by the measurement. 
Link to the code used to validate the rule: https://github.com/JulienPlanque/python-profiling 
Validation result Lancement du conteneur pour le script avoidDoubleQuoteCheckBad.py... 4478091441.0 Lancement du conteneur pour le script avoidDoubleQuoteCheckGood.py... 4478091411.0 Calculation of deltas:
 Delta between bad practice and good code practice for rule AvoidListComprehensionInIterations: 30