Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/benjaminabt/sustainablecode
- Owner: BenjaminAbt
- Created: 2021-10-30T14:24:32.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-27T13:39:17.000Z (29 days ago)
- Last Synced: 2024-11-27T14:36:37.333Z (29 days ago)
- Language: C#
- Homepage:
- Size: 1.73 MB
- Stars: 53
- Watchers: 7
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.