Coder Social home page Coder Social logo

ecoindex_node's People

Contributors

cyve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ecoindex_node's Issues

Issue? Current implementation gives EcoIndex between -5 and 94 instead of 0 to 99

Hi,
I suspect there is an issue (or an inconsistency against the Ecoindex specification) in the current EcoIndex implementation.

As it is currently computed, EcoIndex is between -5 and 94 rather than between 0 and 99 :

  • The smallest possible HTML page (<html></html> containing 3 DOM objects (page + empty header + empty body), generating 1 HTTP request and being 13-byte long) gets an EcoIndex equal to 94.00 (if rounded to 2 digits after the decimal point).
  • The theorically-worst HTML page (594,601 DOM objects; 3,920 HTTP requests; 223,213 kilobytes) gets a EcoIndex equal to -5.

I attached a basic HTML page (designed to be a local file), which computes the EcoIndex number and grade for any manually-entered combination of the 3 input parameters (Dom, Req, Size), based on the current JavaScript implementation of the EcoIndex (as GitHub gives it).
Calculateur EcoIndex.html.txt
This page shows that the returned EcoIndex for a (theorical) HTML page with 0 DOM element, 0 HTTP request, 0-byte long gives an EcoIndex of 95 instead of 100.
It also shows that if you sets the worst value for one parameter and 0 for the 2 others, computed EcoIndex is lower than expected: for instance, the combination of 594,601 DOM objects, 0 HTTP requests and 0 kB gives an EcoIndex of 47.5 instead of the expected 50.

edit> After I created this issue, I found Rachel Pellin's EcoIndex simulator (https://rachelwe.github.io/Simulateur-ecoindex/), which shows the very same behaviour as my attached HTML page.

In my opinion, the issue lies in the calculateIndex function, which should return:
return ((i - 1) + (value - quantiles[i - 1]) / (quantiles[i] - quantiles[i - 1]));
and
return quantiles.length - 1;
instead of:
return (i + (value - quantiles[i - 1]) / (quantiles[i] - quantiles[i - 1]));
and
return quantiles.length;
If such a change were to be made, the grade computation would obviously have to be also altered, by adding 5 to every threshold:
case score >= 80: return 'A';
...
case score >= 10: return 'F';

Incidentally, there is also a typo in the getGreenhouseGasEmmission function name. The 'm' should not be doubled in the word "Emission".

Best Regards,
Olivier Descout

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.