EnergyAnalyzer is a collection of Roslyn Analyzers that provides analysis of language constructs in your code. It gives suggestions of how to improve the energy consumption of your code, and in some cases provides automatic code fixes if the developer chooses to utilize them. The suggestions are based upon research made using the CSharpRAPL (https://gitlab.com/ImDreamer/CsharpRAPL/) framework, and in reports related to the framework (available at https://gitlab.com/ImDreamer/CsharpRAPL/-/blob/main/Benchmarking C# for Energy.pdf) and this analyzer (TBA).
License
—
Deps
1
Install Size
—
Vulns
✓ 0
Published
May 19, 2022
$ dotnet add package EnergyAnalyzerEnergyAnalyzer is a collection of Roslyn Analyzers that can be used to improve the energy efficiency of C# programs.
This project was developed during a masters thesis at Aalborg University, Denmark. The project can be found here (Not published yet).
The suggestions and code fixes implemented in EnergyAnalyzer are based on Benchmarking C# for Energy Consumption (PDF)
The results gathered in both projects are found using CsharpRAPL which is a framework created to benchmark different language constructs in C#.
Further benchmarks can be found here or in the '3rd Party Example Projects' folder.
You can get the analyzer from NuGet here.
The analyzer supports giving suggestions regarding the following topics, with code fixes for some of them (specified):
To install the package, run the following command:
Select the NuGet Package Manager from the Tools menu.
Search for EnergyAnalyzer and click the Install button.
You can install the package from NuGet by one of the following ways:
Install-Package EnergyAnalyzer
dotnet add package EnergyAnalyzer
<PackageReference Include="EnergyAnalyzer" Version="0.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Examples of the changes the tool can make can be seen in the folder "3rd Party Example Projects", where we have used the analyzer to create various versions of the programs.
Such that projects named CodeFixes are the ones that have been changed by the automatic changes and All is where both code fixes and suggestions have been implemented.
Provided is also tasks and examples used for a usability test which resides here.
MIT License
When building your solution you might encounter warnings similar to the one below:
An instance of analyzer EnergyAnalyzer cannot be created from ... : Could not load file or assembly ... or one of its dependencies. The system cannot find the file specified..
This warning does not mean that the analyzer is not working correctly.