energy_consumption_reporter


Nameenergy_consumption_reporter JSON
Version 0.1.7 PyPI version JSON
download
home_pageNone
SummaryAn energy consumption measuring and reporting tool
upload_time2024-03-28 20:17:45
maintainerRodin Haker
docs_urlNone
authorRodin Haker
requires_python<4.0,>=3.10
licenseLICENSE
keywords energy consumption reporter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Scenario Energy Report

**Authors:** Delano Flipse, Rodin Haker, Aron Hoogeveen


## Setup

This project uses Python 3.10.

## Description

This tool offers developers a method to gauge energy and power consumption at a per-function level. By default it leverages the [spec-power-model](https://github.com/green-coding-solutions/spec-power-model) developed by Green Coding Solutions for power measurement, utilizing CPU utilization of the program executing the function under test.

The tool automatically detects the hardware specification of the system it is used on and trains the model to accurately capture the energy consumption patterns. This process utilizes the [TDP list](https://github.com/mlco2/codecarbon/blob/master/codecarbon/data/hardware/cpu\_power.csv}{https://github.com/mlco2/codecarbon/blob/master/codecarbon/data/hardware/cpu\_power.csv) provided by CodeCarbon to retrieve the TDP for the CPU.

The measuring process can be started in two ways, as discussed in [Usage](#Usage). It will then proceed to measure the program from a separate process.

Finally, you can set up the tool to output a JSON file, print the report in the terminal, both, or neither.

## Dependencies

### Windows
As of now, no specific requirements are identified.

### Linux

- [lm-sensors](https://github.com/lm-sensors/lm-sensors) - the command `sensors -j` is used for extracting information about the CPU temperature.

## Installation

### Using Poetry (Recommended)
```console
poetry add energy_consumption_reporter
```

### Using PIP
```console
pip install energy_consumption_reporter
```

### Submodule / Download
Alternatively, you have the option to download this repository or add it as a submodule and integrate it into your own projects. This approach allows you to customize the tool according to your preferences and make any necessary adjustments as needed.

#### Add submodule
```console
git submodule add https://github.com/aron-hoogeveen/energy-consumption-reporter.git <destination-folder>
```

#### Pull submodule
```console
git submodule update --init
```

#### Update submodule
```console
git submodule update --remote --merge
```

## Usage

First you must import the module:

```python
from energy_consumption_reporter.energy_tester import EnergyTester, OutputType
```

There are two main ways to use this project:

1. Implement the decorator to test a function. You can specify the number of iterations as a parameter.

``` python
@EnergyTest.energy_test(2)
def test_func():
    def fib(n):
        if n <= 1:
            return n
        else:
            return fib(n-1) + fib(n-2)

    assert fib(37) == 24157817, "Not equal"
```

2. Utilize a with statement to test a specific code segment once.

``` python
def test_func3():
    with EnergyTest() as test:
        def fib(n):
            if n <= 1:
                return n
            else:
                return fib(n-1) + fib(n-2)

        assert fib(35) == 9227465, "Not equal"
```

You have the flexibility to configure the following custom parameters:
- Model (default = [spec-power-model](https://github.com/green-coding-solutions/spec-power-model) by Green Coding Solutions)
- Report name (default = CPU Energy Test Report)
- Report description (default = empty)
- Option to save a report in JSON format (default = NONE)

These parameters need to be configured before calling the functions. Refer to the [example.py](https://github.com/aron-hoogeveen/energy-consumption-reporter/blob/main/example.py) file for more details and examples.

``` python
EnergyTest().set_model(MyCustomModel)
EnergyTest().set_report_name("Custom Report Name")
EnergyTest().set_report_description("Custom Report Description")
EnergyTest().set_save_report(OutputType.PRINT_JSON)
```

If the option 'set_save_report' is set to True, the tool will generate [a JSON file](https://github.com/aron-hoogeveen/energy-consumption-reporter/blob/main/reporterdashboard/example-reports/report1.json) containing the output data. When set to False it prints the same information to the terminal.

## Pytest plugin

This tool has been integrated into [pytest-energy-reporter](https://github.com/delanoflipse/pytest-energy-reporter), a pytest plugin designed to seamlessly incorporate energy metrics into pytest's reporting capabilities.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "energy_consumption_reporter",
    "maintainer": "Rodin Haker",
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": "rodinhaker@hotmail.com",
    "keywords": "energy, consumption, reporter",
    "author": "Rodin Haker",
    "author_email": "rodinhaker@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ca/d3/71a0fded0035f5eed8d81eb4e5d114fea51261a001b42fb054368d4fade5/energy_consumption_reporter-0.1.7.tar.gz",
    "platform": null,
    "description": "# Scenario Energy Report\n\n**Authors:** Delano Flipse, Rodin Haker, Aron Hoogeveen\n\n\n## Setup\n\nThis project uses Python 3.10.\n\n## Description\n\nThis tool offers developers a method to gauge energy and power consumption at a per-function level. By default it leverages the [spec-power-model](https://github.com/green-coding-solutions/spec-power-model) developed by Green Coding Solutions for power measurement, utilizing CPU utilization of the program executing the function under test.\n\nThe tool automatically detects the hardware specification of the system it is used on and trains the model to accurately capture the energy consumption patterns. This process utilizes the [TDP list](https://github.com/mlco2/codecarbon/blob/master/codecarbon/data/hardware/cpu\\_power.csv}{https://github.com/mlco2/codecarbon/blob/master/codecarbon/data/hardware/cpu\\_power.csv) provided by CodeCarbon to retrieve the TDP for the CPU.\n\nThe measuring process can be started in two ways, as discussed in [Usage](#Usage). It will then proceed to measure the program from a separate process.\n\nFinally, you can set up the tool to output a JSON file, print the report in the terminal, both, or neither.\n\n## Dependencies\n\n### Windows\nAs of now, no specific requirements are identified.\n\n### Linux\n\n- [lm-sensors](https://github.com/lm-sensors/lm-sensors) - the command `sensors -j` is used for extracting information about the CPU temperature.\n\n## Installation\n\n### Using Poetry (Recommended)\n```console\npoetry add energy_consumption_reporter\n```\n\n### Using PIP\n```console\npip install energy_consumption_reporter\n```\n\n### Submodule / Download\nAlternatively, you have the option to download this repository or add it as a submodule and integrate it into your own projects. This approach allows you to customize the tool according to your preferences and make any necessary adjustments as needed.\n\n#### Add submodule\n```console\ngit submodule add https://github.com/aron-hoogeveen/energy-consumption-reporter.git <destination-folder>\n```\n\n#### Pull submodule\n```console\ngit submodule update --init\n```\n\n#### Update submodule\n```console\ngit submodule update --remote --merge\n```\n\n## Usage\n\nFirst you must import the module:\n\n```python\nfrom energy_consumption_reporter.energy_tester import EnergyTester, OutputType\n```\n\nThere are two main ways to use this project:\n\n1. Implement the decorator to test a function. You can specify the number of iterations as a parameter.\n\n``` python\n@EnergyTest.energy_test(2)\ndef test_func():\n    def fib(n):\n        if n <= 1:\n            return n\n        else:\n            return fib(n-1) + fib(n-2)\n\n    assert fib(37) == 24157817, \"Not equal\"\n```\n\n2. Utilize a with statement to test a specific code segment once.\n\n``` python\ndef test_func3():\n    with EnergyTest() as test:\n        def fib(n):\n            if n <= 1:\n                return n\n            else:\n                return fib(n-1) + fib(n-2)\n\n        assert fib(35) == 9227465, \"Not equal\"\n```\n\nYou have the flexibility to configure the following custom parameters:\n- Model (default = [spec-power-model](https://github.com/green-coding-solutions/spec-power-model) by Green Coding Solutions)\n- Report name (default = CPU Energy Test Report)\n- Report description (default = empty)\n- Option to save a report in JSON format (default = NONE)\n\nThese parameters need to be configured before calling the functions. Refer to the [example.py](https://github.com/aron-hoogeveen/energy-consumption-reporter/blob/main/example.py) file for more details and examples.\n\n``` python\nEnergyTest().set_model(MyCustomModel)\nEnergyTest().set_report_name(\"Custom Report Name\")\nEnergyTest().set_report_description(\"Custom Report Description\")\nEnergyTest().set_save_report(OutputType.PRINT_JSON)\n```\n\nIf the option 'set_save_report' is set to True, the tool will generate [a JSON file](https://github.com/aron-hoogeveen/energy-consumption-reporter/blob/main/reporterdashboard/example-reports/report1.json) containing the output data. When set to False it prints the same information to the terminal.\n\n## Pytest plugin\n\nThis tool has been integrated into [pytest-energy-reporter](https://github.com/delanoflipse/pytest-energy-reporter), a pytest plugin designed to seamlessly incorporate energy metrics into pytest's reporting capabilities.",
    "bugtrack_url": null,
    "license": "LICENSE",
    "summary": "An energy consumption measuring and reporting tool",
    "version": "0.1.7",
    "project_urls": {
        "Bug Tracker": "https://github.com/aron-hoogeveen/energy-consumption-reporter/issues",
        "Documentation": "https://github.com/aron-hoogeveen/energy-consumption-reporter",
        "Homepage": "https://github.com/aron-hoogeveen/energy-consumption-reporter",
        "Repository": "https://github.com/aron-hoogeveen/energy-consumption-reporter"
    },
    "split_keywords": [
        "energy",
        " consumption",
        " reporter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a73e2566435b045c0ffb39c1119b1549c8b8d66c30b237460030597dad0919f",
                "md5": "5f4a62e98af3530a1cc82a07eb2440b0",
                "sha256": "ff659910fa1ef98c16fa3c5ba5d303375c827ae9b4df5952daebd094e4074334"
            },
            "downloads": -1,
            "filename": "energy_consumption_reporter-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5f4a62e98af3530a1cc82a07eb2440b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 3256426,
            "upload_time": "2024-03-28T20:17:42",
            "upload_time_iso_8601": "2024-03-28T20:17:42.831704Z",
            "url": "https://files.pythonhosted.org/packages/0a/73/e2566435b045c0ffb39c1119b1549c8b8d66c30b237460030597dad0919f/energy_consumption_reporter-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cad371a0fded0035f5eed8d81eb4e5d114fea51261a001b42fb054368d4fade5",
                "md5": "ff551df1e6399d078cf3d0224bb72e1a",
                "sha256": "4be47807fde313944de96c99cf0dbe50e513df0b1e548f5e7d99b845468522eb"
            },
            "downloads": -1,
            "filename": "energy_consumption_reporter-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "ff551df1e6399d078cf3d0224bb72e1a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 3233035,
            "upload_time": "2024-03-28T20:17:45",
            "upload_time_iso_8601": "2024-03-28T20:17:45.916666Z",
            "url": "https://files.pythonhosted.org/packages/ca/d3/71a0fded0035f5eed8d81eb4e5d114fea51261a001b42fb054368d4fade5/energy_consumption_reporter-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-28 20:17:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aron-hoogeveen",
    "github_project": "energy-consumption-reporter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "energy_consumption_reporter"
}
        
Elapsed time: 3.36346s