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

[CRPYT] [Python] Use numpy array instead of standard list #132

Closed
misterdz-mh opened this issue Apr 6, 2023 · 4 comments
Closed

[CRPYT] [Python] Use numpy array instead of standard list #132

misterdz-mh opened this issue Apr 6, 2023 · 4 comments
Assignees
Labels
🗃️ rule rule improvment or rule development or bug 🏆 challenge2023 🏆 Work done during the ecoCode Challenge __PRIO_MEDIUM__ python

Comments

@misterdz-mh
Copy link

TEAM 487

@dedece35 dedece35 added 🗃️ rule rule improvment or rule development or bug python 🏆 challenge2023 🏆 Work done during the ecoCode Challenge labels Apr 6, 2023
@dedece35 dedece35 changed the title CRPYT - 904000m2 - Use numpy array instead of standard list CRPYT - Use numpy array instead of standard list Aug 25, 2023
@dedece35 dedece35 changed the title CRPYT - Use numpy array instead of standard list [CRPYT] [Python] Use numpy array instead of standard list Aug 25, 2023
@dedece35
Copy link
Member

dedece35 commented Sep 22, 2023

TO DISCUSS INSIDE CORE-TEAM : issue to close ? no existing PR but really in project Kanban
(https://github.com/orgs/green-code-initiative/projects/1?pane=issue&itemId=24907316)

@jhertout
Copy link
Contributor

jhertout commented Oct 6, 2023

We perform some basic measures for this rule and the result were not satisfying. If there is an advantage to use numpy it must be detailed. I think we should close this one.

Here are the things we tested :

Use numpy array instead of standard list

A - Construction d'une liste

1 - Non compliant

list(range(1000000))

2 - Compliant

np.arange(1000000)

B - Itération d'une liste

1 - Non compliant

Liste utilisé :

my_list = list(range(1000000))

Code testé :

for item in my_list:
    tmp = item

2 - Compliant

Liste utilisé :

my_list = np.arange(1000000)

Code testé :

for item in my_list:
    tmp = item

C - Récupération d'un élément d'une liste

1 - Non compliant

Liste utilisé :

my_list = list(range(1000000))

Code testé :

tmp = my_list[500000]

2 - Compliant

Liste utilisé :

my_list = np.arange(1000000)

Code testé :

tmp = my_list[500000]

And the results of the measures :

Use numpy array instead of standard list

A - Construction d'une liste

Itération : 500

1 - Non compliant

Numéro d'itération Consommation en Joules Temps d'exécution en secondes Rapport J/s
1 226.73 14.211546971 15.95392820
2 225.80 13.973445392 16.15922155
3 226.30 14.076505224 16.07643348
4 228.87 14.204236174 16.11279882
5 228.34 14.237142466 16.03833076
6 227.08 14.153487727 16.04410194
7 228.23 14.236500496 16.03132736
8 225.82 14.057398904 16.06413829
9 228.24 14.183727774 16.09167939
10 227.67 14.150479407 16.08920754
11 227.71 14.100659046 16.14889057
12 228.29 14.250680476 16.01958589
13 226.63 14.118486547 16.05200382
14 225.51 14.022863767 16.08159387
15 224.61 14.024847034 16.01514793
16 225.64 14.026694030 16.08647051
17 227.28 14.123749114 16.09204455
18 227.58 14.073604854 16.17069701
19 229.07 14.165816004 16.17061805
20 229.36 14.147023417 16.21259774

2 - Compliant

Numéro d'itération Consommation en Joules Temps d'exécution en secondes Rapport J/s
1 6.58 0.298146448 22.06969106
2 6.67 0.295191261 22.59551985
3 6.82 0.297514261 22.92327089
4 6.82 0.297843323 22.89794490
5 6.67 0.297768124 22.39997992
6 6.70 0.295827283 22.64835052
7 6.72 0.299124966 22.46552699
8 6.62 0.295482665 22.40402156
9 6.77 0.296678858 22.81928697
10 6.69 0.294887133 22.68664601
11 6.64 0.294725764 22.52941822
12 6.73 0.299843733 22.44502472
13 6.65 0.294155281 22.60710729
14 6.72 0.297277877 22.60511299
15 6.69 0.294785327 22.69448099
16 6.68 0.296182546 22.55365851
17 6.70 0.295367076 22.68363857
18 6.67 0.295390171 22.58030447
19 6.71 0.296991203 22.59326179
20 6.65 0.293984978 22.62020340

B - Itération d'une liste

Itération : 200

1 - Non compliant

Numéro d'itération Consommation en Joules Temps d'exécution en secondes Rapport J/s
1 143.41 8.173361236 17.54602492
2 144.98 8.303619395 17.45985613
3 131.78 7.501407735 17.56736930
4 132.06 7.502569370 17.60196987
5 137.56 7.903276506 17.40543936
6 137.19 7.734243464 17.73799863
7 140.43 7.920118769 17.73079471
8 145.29 8.167104089 17.78965939
9 145.37 8.309516583 17.49439916
10 134.33 7.706901237 17.42983280
11 136.23 7.700913954 17.69010805
12 152.16 8.639646176 17.61183234
13 138.73 7.906341411 17.54667459
14 138.64 7.866312787 17.62452164
15 133.13 7.501496175 17.74712629
16 135.72 7.694811850 17.63785816
17 135.94 7.650249324 17.76935551
18 133.72 7.510285395 17.80491592
19 153.59 8.690937717 17.67243133
20 146.30 8.323642714 17.57643918

2 - Compliant

Numéro d'itération Consommation en Joules Temps d'exécution en secondes Rapport J/s
1 237.36 12.779763873 18.57311311
2 241.67 13.081704894 18.47389174
3 239.73 12.787814427 18.74675311
4 242.82 13.071383557 18.57645741
5 235.85 12.769037699 18.47045999
6 239.07 12.778712854 18.70845700
7 237.21 12.786104169 18.55217170
8 246.36 13.305249354 18.51600022
9 248.10 13.335602493 18.60433378
10 247.69 13.342719391 18.56368201
11 239.13 12.811708422 18.66495803
12 242.88 13.038682697 18.62764863
13 240.70 13.075853225 18.40797658
14 241.07 13.077014954 18.43463518
15 236.63 12.816065218 18.46354524
16 236.28 12.758304294 18.51970250
17 255.53 13.712045731 18.63543959
18 238.95 12.925029380 18.48738544
19 243.28 13.134115617 18.52275456
20 251.90 13.538669159 18.60596466

C - Récupération d'un élément d'une liste

Itération : 100.000.000

1 - Non compliant

Numéro d'itération Consommation en Joules Temps d'exécution en secondes Rapport J/s
1 109.24 6.259988527 17.45051121
2 99.44 5.734942290 17.33932007
3 102.04 5.846834486 17.45217865
4 106.62 6.102100406 17.47267217
5 101.69 5.814824555 17.48805987
6 99.86 5.725344921 17.44174392
7 107.80 6.033074307 17.86817044
8 107.30 6.150831456 17.44479600
9 101.69 5.840219330 17.41201729
10 107.77 6.184935986 17.42459424
11 100.78 5.734545254 17.57419211
12 103.52 5.782912192 17.90101536
13 103.35 5.850249311 17.66591379
14 103.95 5.905713920 17.60159760
15 103.34 5.919728349 17.45688212
16 100.43 5.731974073 17.52101435
17 103.11 5.907553667 17.45392523
18 103.12 5.792451412 17.80247992
19 104.91 6.026638367 17.40771448
20 100.95 5.748075928 17.56239849

2 - Compliant

Numéro d'itération Consommation en Joules Temps d'exécution en secondes Rapport J/s
1 189.52 10.145179463 18.68079324
2 190.63 10.217838957 18.65658685
3 219.37 12.441805554 17.63168529
4 188.30 10.103760791 18.63662490
5 191.76 10.268583140 18.67443613
6 194.17 10.378052149 18.70967665
7 183.96 10.007252852 18.38266732
8 191.92 10.279490444 18.67018613
9 188.44 10.096896236 18.66316099
10 196.46 10.530679005 18.65596699
11 186.98 10.006633914 18.68560413
12 196.30 10.466818655 18.75450473
13 195.05 10.440584045 18.68190506
14 186.40 10.033753463 18.57729519
15 186.02 10.157204095 18.31409492
16 190.14 10.163845529 18.70748620
17 198.29 10.631342053 18.65145519
18 187.58 10.059887267 18.64633221
19 186.93 9.986243065 18.71875126
20 190.74 10.181448440 18.73407316

We can see that the results for the iteration and the access of an element of the list are not so efficient in term of energy. The rule cannot be integrated in this state.

@glalloue
Copy link
Contributor

glalloue commented Oct 6, 2023

Related to previous results, this rule is not relevant.
This issue will be closed and can be reopened if new results show Numpy could be better than a standard list.

A new rules list will be created to list studied rules but refused to archive it and keep results somewhere

(seen with @jhertout and @dedece35 )

@dedece35
Copy link
Member

dedece35 commented Oct 6, 2023

as discussed, I affect this issue to @jhertout to initiate a doc to reference Rules refused or deleted (with reference to issue / PR dealing with discussion about the decision)
next @jhertout will clos this issue

  • initiate doc for refused / deleted rules : check Rules.md: Refused rules #234
  • mark as done the ticket of this rule on Kanban project
  • close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗃️ rule rule improvment or rule development or bug 🏆 challenge2023 🏆 Work done during the ecoCode Challenge __PRIO_MEDIUM__ python
Projects
None yet
Development

No branches or pull requests

4 participants