Skip to content

Commit 5284bac

Browse files
committed
Merge branch 'dev'
2 parents cd44976 + b0da529 commit 5284bac

197 files changed

Lines changed: 43452 additions & 27347 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ StyleCopReport.xml
9595
*.pidb
9696
*.svclog
9797
*.scc
98+
*.dll
9899

99100
# Chutzpah Test files
100101
_Chutzpah*

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Kevin Zehrer
3+
Copyright (c) 2024-2025 Kevin Zehrer
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,69 @@
11
# KZDev.PerfUtils
22

3-
This is the repository for the ['KZDev.PerfUtils'](https://www.nuget.org/packages/KZDev.PerfUtils) nuget package that contains the `MemoryStreamSlim` class; a high-performance, memory-efficient, and easy-to-use replacement for the `MemoryStream` class that provides particular benefits for large or frequently used streams. As well as the `StringBuilderCache` which allows better performance when using `StringBuilder` instances, and the `InterlockedOps` class, which provides additional atomic thread-safe operations to extend the functionality of the `Interlocked` class in the .NET Class Library.
3+
This repository contains the ['KZDev.PerfUtils'](https://www.nuget.org/packages/KZDev.PerfUtils) NuGet package, which provides the following high-performance utilities:
4+
5+
- **MemoryStreamSlim**: A memory-efficient, high-performance replacement for the MemoryStream class, offering significant benefits for large or frequently used streams.
6+
- **StringBuilderCache**: A utility for caching StringBuilder instances to improve performance in high-throughput scenarios.
7+
- **InterlockedOps**: A set of additional atomic thread-safe operations that extend the functionality of the Interlocked class in the .NET Class Library.
8+
9+
## Performance Highlights
10+
11+
This sampling of performance benchmarks clearly demonstrates the advantages of using the KZDev.PerfUtils package:
12+
13+
![StringBuilderCache Performance Sample](https://raw.githubusercontent.com/kzdev-net/kzdev.perfutils/refs/heads/main/Source/Src/KZDev.PerfUtils/Package/v2.0/images/stringbuilder_sample.jpg)
14+
15+
![MemoryStreamSlim Performance Sample](https://raw.githubusercontent.com/kzdev-net/kzdev.perfutils/refs/heads/main/Source/Src/KZDev.PerfUtils/Package/v2.0/images/memorystreamslim_sample.jpg)
16+
17+
For more details, refer to the benchmark related pages in the [documentation](https://kzdev-net.github.io/kzdev.perfutils/).
418

519
## Features
620

7-
`MemoryStreamSlim` is a drop-in replacement for the `MemoryStream` class that provides the following benefits:
21+
### MemoryStreamSlim
22+
23+
`MemoryStreamSlim` is a drop-in replacement for the **MemoryStream** class, offering the following advantages:
24+
25+
- **Improved Throughput**: Outperforms the standard MemoryStream in terms of throughput.
26+
- **Reduced Memory Traffic**: Significantly lowers memory traffic and garbage collection compared to the standard MemoryStream.
27+
- **Eliminates LOH Fragmentation**: Prevents Large Object Heap (LOH) fragmentation caused by frequent use and release of single-byte arrays.
28+
- **API Compatibility**: Provides the same API as MemoryStream, with minor differences in the constructor.
29+
- **Optional Native Memory Storage**: Allows the use of native memory for storage, further reducing GC pressure and increasing flexibility.
30+
31+
### StringBuilderCache
832

9-
* Throughput performance is better than the standard `MemoryStream`.
10-
* Much lower memory traffic and far fewer garbage collections than the standard `MemoryStream`.
11-
* Eliminates Large Object Heap (LOH) fragmentation caused by frequent use and release of single-byte arrays used by the standard `MemoryStream`.
12-
* Simple replacement for `MemoryStream` with the same API, other than the constructor.
13-
* Optionally allows using native memory for storage, which allows even more flexibility to minimize GC pressure.
33+
`StringBuilderCache` is a static class that provides a thread-safe cache of StringBuilder instances, reducing allocations and deallocations in high-throughput scenarios. Key features include:
1434

15-
`StringBuilderCache` is a static class that provides a thread-safe cache of `StringBuilder` instances to reduce the number of allocations and deallocations of `StringBuilder` objects in high-throughput scenarios with simple operations:
35+
- **Acquire**: Retrieve a StringBuilder instance from the cache.
36+
- **Release**: Return a StringBuilder instance to the cache.
37+
- **GetStringAndRelease**: Retrieve the string from a StringBuilder instance and return it to the cache.
38+
- **GetScope**: Use a using-scoped StringBuilder instance, which is automatically returned to the cache when the scope is exited.
39+
- **Monitoring**: Leverages the .NET runtime's Events feature for detailed cache management and monitoring.
1640

17-
* Acquire : Get a `StringBuilder` instance from the cache.
18-
* Release : Return a `StringBuilder` instance to the cache.
19-
* GetStringAndRelease : Get the string from a `StringBuilder` instance and return it to the cache.
20-
* GetScope : Get a `using` scoped `StringBuilder` instance from the cache and return it to the cache when the scope is exited.
21-
* Monitoring with `Events` feature of the .NET runtime for detailed cache management.
41+
### InterlockedOps
2242

23-
`InterlockedOps` is a static class providing the following thread-safe atomic operations:
43+
`InterlockedOps` is a static class that provides additional thread-safe atomic operations for integer types, including:
2444

25-
* Xor : Exclusive OR operation on any integer types.
26-
* ClearBits : Clear bits on any integer types.
27-
* SetBits : Set bits on any integer types.
28-
* ConditionAnd : Conditionally update bits using an AND operation on any integer types.
29-
* ConditionOr : Conditionally update bits using an OR operation on any integer types.
30-
* ConditionXor : Conditionally update bits using an XOR operation on any integer types.
31-
* ConditionClearBits : Conditionally clear bits on any integer types.
32-
* ConditionSetBits : Conditionally set bits on any integer types.
45+
- **Xor**: Perform an exclusive OR operation.
46+
- **ClearBits**: Clear specific bits.
47+
- **SetBits**: Set specific bits.
48+
- **ConditionAnd**: Conditionally update bits using an AND operation.
49+
- **ConditionOr**: Conditionally update bits using an OR operation.
50+
- **ConditionXor**: Conditionally update bits using an XOR operation.
51+
- **ConditionClearBits**: Conditionally clear specific bits.
52+
- **ConditionSetBits**: Conditionally set specific bits.
3353

3454
## Documentation
3555

36-
Full documentation for the package is available on the [PerfUtils Documentation](https://kzdev-net.github.io/kzdev.perfutils/) page.
56+
Comprehensive documentation for the package is available on the [PerfUtils Documentation](https://kzdev-net.github.io/kzdev.perfutils/) page.
3757

3858
## Future Features
3959

40-
The roadmap plan for this package is to add several additional helpful performance focused utilities as time allows.
60+
The roadmap for this package includes plans to add additional performance-focused utilities as time allows.
4161

4262
## Contribution Guidelines
4363

44-
At this time, I am not accepting external pull requests. However, any feedback or suggestions are welcome and can be provided through the following channels:
64+
At this time, external pull requests are not being accepted. However, feedback and suggestions are welcome through the following channels:
4565

46-
- **Feature Requests:** Please use GitHub Discussions to discuss new features or enhancements before opening a feature request. This will help ensure that your request is in line with the project's goals and vision.
47-
- **Bug Reports:** If you encounter any issues, feel free to open an issue so it can be addressed promptly.
66+
- **Feature Requests**: Use GitHub Discussions to propose new features or enhancements. This ensures alignment with the project's goals and vision before opening a feature request.
67+
- **Bug Reports**: If you encounter any issues, please open an issue on GitHub to report them.
4868

49-
I appreciate your understanding and look forward to collaborating with you through discussions and issue tracking.
69+
Your understanding is appreciated, and I look forward to collaborating with you through discussions and issue tracking.

0 commit comments

Comments
 (0)