Skip to content

Commit bfb09f5

Browse files
committed
Updating readme and claude files
1 parent 53b14f3 commit bfb09f5

File tree

4 files changed

+114
-1
lines changed

4 files changed

+114
-1
lines changed

CLAUDE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dotnet test
2828
dotnet test --logger:"console;verbosity=detailed"
2929

3030
# Run a specific test class
31-
dotnet test --filter "FullyQualifiedName~StringPoolTest"
31+
dotnet test --filter "FullyQualifiedName~UnmanagedStringPoolTests"
3232

3333
# Run a specific test method
3434
dotnet test --filter "FullyQualifiedName~TestClassName.TestMethodName"
@@ -47,6 +47,9 @@ dotnet build --no-incremental
4747

4848
# Format code after making changes
4949
dotnet format
50+
51+
# Verify code is properly formatted without making changes
52+
dotnet format --verify-no-changes
5053
```
5154

5255
**IMPORTANT**: Always run `dotnet format` after making any code changes to ensure consistent formatting.

Demo/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# UnmanagedStringPool Demo
2+
3+
This directory contains a demonstration application showing practical usage of the UnmanagedStringPool library.
4+
5+
## Overview
6+
7+
The demo application (`Demo.cs`) provides a hands-on example of:
8+
- Creating and managing a string pool
9+
- Allocating and freeing strings
10+
- String manipulation operations
11+
- Pool memory statistics and fragmentation monitoring
12+
- Pool growth and defragmentation
13+
14+
## Running the Demo
15+
16+
```bash
17+
# From the Demo directory
18+
dotnet run
19+
20+
# Or from the project root
21+
dotnet run --project Demo/StringPoolDemo.csproj
22+
```
23+
24+
## Demo Features
25+
26+
### Basic Operations
27+
- String allocation from the pool
28+
- Value semantics demonstration (struct equality)
29+
- String freeing and memory reuse
30+
- Using statement integration with disposable strings
31+
32+
### String Manipulation
33+
- String insertion operations
34+
- Replacement and trimming
35+
- Substring extraction
36+
- Case conversion
37+
38+
### Memory Management
39+
- Real-time fragmentation monitoring
40+
- Free space tracking
41+
- Active allocation counting
42+
- Forced defragmentation and pool growth
43+
44+
### Performance Comparison
45+
- Timing comparisons between pooled and regular strings
46+
- Memory allocation stress testing
47+
- GC pressure demonstration
48+
49+
## Sample Output
50+
51+
```
52+
Value semantics, does Hello == Hello? False
53+
Hello
54+
World
55+
This is a longer string
56+
Free space before: 3968
57+
End block space: 3968
58+
Active allocations: 4
59+
Fragmentation: 0.00%
60+
...
61+
After pool growth:
62+
Free space after: 8064
63+
End block space: 8064
64+
Active allocations: 4
65+
Fragmentation: 0.00%
66+
```
67+
68+
## Key Learning Points
69+
70+
1. **Struct Semantics**: PooledString instances are value types with reference equality semantics
71+
2. **Memory Efficiency**: See how freed memory is immediately reused
72+
3. **Fragmentation**: Observe fragmentation patterns and defragmentation in action
73+
4. **Growth**: Watch the pool automatically grow when needed
74+
5. **Disposal**: Proper resource cleanup with using statements
75+
76+
## Customization
77+
78+
Modify the demo to experiment with:
79+
- Different initial pool sizes
80+
- Various string allocation patterns
81+
- Concurrent access scenarios (with proper synchronization)
82+
- Large-scale string operations
83+
- Custom fragmentation thresholds

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ str1.Dispose();
8989
// Pool automatically cleans up remaining allocations on disposal
9090
```
9191

92+
## Test Suite
93+
94+
The project includes comprehensive test coverage across multiple areas:
95+
96+
- **UnmanagedStringPoolTests.cs**: Core functionality and basic operations
97+
- **UnmanagedStringPoolEdgeCaseTests.cs**: Edge cases and error conditions
98+
- **FragmentationAndMemoryTests.cs**: Memory management and defragmentation
99+
- **FragmentationTest.cs**: Specific fragmentation scenarios
100+
- **PooledStringTests.cs**: String operations and manipulations
101+
- **ConcurrentAccessTests.cs**: Thread safety and concurrent operations
102+
- **DisposalAndLifecycleTests.cs**: Object disposal and lifecycle management
103+
- **FinalizerBehaviorTests.cs**: Finalizer and GC interaction tests
104+
- **ClearMethodTests.cs**: Pool clearing operations
105+
- **IntegerOverflowTests.cs**: Overflow protection and boundary conditions
106+
92107
## Performance Characteristics
93108

94109
- **Allocation**: O(1) average case with size-indexed free lists
@@ -114,6 +129,12 @@ dotnet test
114129

115130
# Run with detailed output
116131
dotnet test --logger:"console;verbosity=detailed"
132+
133+
# Run specific test class
134+
dotnet test --filter "FullyQualifiedName~UnmanagedStringPoolTests"
135+
136+
# Format code (important after making changes)
137+
dotnet format
117138
```
118139

119140
For detailed information about the test suite and coverage areas, see [Tests/README.md](Tests/README.md).

Tests/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ This directory contains comprehensive tests for the UnmanagedStringPool implemen
3232
- Memory efficiency validation
3333
- Stress testing with interleaved operations
3434

35+
**`FragmentationTest.cs`** - *Specific fragmentation scenario testing*
36+
- Focused fragmentation pattern creation
37+
- Fragmentation percentage calculation validation
38+
- Defragmentation trigger testing
39+
- Memory compaction verification
40+
3541
**`FinalizerBehaviorTests.cs`** - *Unmanaged resource cleanup and finalizer execution*
3642
- Finalizer execution without explicit disposal
3743
- Memory leak prevention validation

0 commit comments

Comments
 (0)