Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/benjaminabt/sustainablecode

Sustainable Code Samples and Patterns by BEN ABT
https://github.com/benjaminabt/sustainablecode

Last synced: 22 days ago
JSON representation

Sustainable Code Samples and Patterns by BEN ABT

Awesome Lists containing this project

README

        

# 🌳 Sustainable Code - by BEN ABT

Sustainable applications are becoming increasingly important, because more and more energy consumption is attributable to the operations of a platform or application.

On the user side, this can be seen in the battery life of a laptop or cell phone and as a platform operator, it can be seen in the costs of compute power.
In this repository I use well-known and daily snippets and compare them to sustainable implementations.

It's worth it!

## .NET Samples

Code samples and snippets based on .NET

[.NET Object Pooling with StringBuilder](csharp/stringbuilder-pooled)

[.NET Less Allocations with Hyperlinq](csharp/hyperlinq-tolist)

[.NET Low Allocation Log Message Generation](csharp/log-messages-source-code-generator)

[.NET String Generation](csharp/random-string)

[.NET Struct vs Class](csharp/struct-vs-class)

[.NET Local method hot path](csharp/local-method-hotpath)

[.NET C# 10 String Interpolation](csharp/csharp10-string-interpolation)

[.NET List vs HashSet](csharp/list-vs-hashset)

[.NET In Modifier](csharp/in-parameter)

[.NET Create Empty Collection](csharp/create-empty-collection)

[.NET String ToUpper vs. ToLower](csharp/tolower-vs-toupper)

[.NET Enumerate List vs. IEnumerable](csharp/list-vs-ienumerable-enumerate)

[.NET List Count vs Count()](csharp/list-count-property-vs-count-method)

[.NET DateTime vs. DateTimeOffset - UtcNow vs Now](csharp/datime-now-vs-utcnow)

[.NET Linq Compiled Expressions](csharp/linq-expression-compile)

[.NET Nullable Value Access (Pattern Matching)](csharp/nullable-value-access)

[.NET String Create Value Stringbuilder)](csharp/valuestringbuilder)

[.NET Avoid List Allocations)](csharp/avoid-list-allocations)

[.NET Struct vs Class- Boxing](csharp/struct-vs-class-boxing)

[.NET Condition vs Exception](csharp/condition-vs-exception)

[.NET SHA512 Create](csharp/Sha512-Create-Speed)

[.NET Linq - Any vs Count](csharp/linq-any-vs-count)

[.NET List ConvertAll vs Select-ToList](csharp/list-convertall-vs-select-tolist)

[.NET String Cleanup](csharp/string-cleanup)

[.NET List Empty Return](csharp/list-empty-return)

[.NET Whitespace Remove](csharp/whitespace-remove)

## Energy Calculation

The energy consumption of an application itself is comparatively complex to measure and often inaccurate. Therefore, proxy measurements are mostly used: the better an application performs, the less energy is required.

The combination of the performance of the code and the energy consumption of the hardware then results in the CO2 footprint, for example.