diff --git a/src/ExampleProject/Views/Home/Docs.cshtml b/src/ExampleProject/Views/Home/Docs.cshtml index 1b91857..31b3c02 100644 --- a/src/ExampleProject/Views/Home/Docs.cshtml +++ b/src/ExampleProject/Views/Home/Docs.cshtml @@ -522,7 +522,7 @@ options.CachedCustomSuffixes = new[] { The foundation layer containing all number formatting logic and performance optimizations.
All formatting operations use stack-based allocation unless the result exceeds buffer size.
@@ -640,7 +640,7 @@ options.CachedCustomSuffixes = new[] {The HumanNumbers core library provides comprehensive number formatting capabilities with - zero-allocation performance and extensive customization options. + Low-Allocation performance and extensive customization options.
- HumanNumbers is designed from the ground up for maximum performance with zero-allocation + HumanNumbers is designed from the ground up for maximum performance with Low-Allocation operations, Span<char> usage, and JIT optimizations. The library maintains consistent sub-microsecond formatting times even under high load.
Stack-based formatting for most operations
@@ -1381,11 +1381,11 @@ public class HumanNumberErrorHandlingMiddleware- Zero-allocation design with stack-based operations: + Low-Allocation design with stack-based operations:
// Zero allocation for most operations
+ // Low Allocation for most operations
Span buffer = stackalloc char[32];
var success = 1500000.TryFormatHuman(buffer, out var written, out var result);
// No heap allocation - result points to stack buffer
@@ -1402,7 +1402,7 @@ public static bool TryFormatHuman(
out string result)
{
// Implementation uses stackalloc and Span
- // Zero allocation when result fits in buffer
+ // Low Allocation when result fits in buffer
}
// BenchmarkDotNet results
-| Method | Mean | Allocated |
-|--------------------------|----------|----------|
-| HumanNumbers.ToHuman | 85.21 ns | 0 B |
-| String.Format("N0") | 342.15 ns| 96 B |
-| ToString("N0") | 287.43 ns| 96 B |
-| CustomFormatter | 156.78 ns| 32 B |
-
-// Large dataset performance
-| Dataset Size | HumanNumbers | String.Format | Improvement |
-|--------------|---------------|--------------|-------------|
-| 1K items | 0.085 ms | 0.342 ms | 4.0x |
-| 10K items | 0.852 ms | 3.421 ms | 4.0x |
-| 100K items | 8.521 ms | 34.215 ms | 4.0x |
-| 1M items | 85.21 ms | 342.15 ms | 4.0x |
-
-// Memory allocation comparison
-| Operation | HumanNumbers | Standard Format |
-|--------------------|---------------|-----------------|
-| Single format | 0 B | 96 B |
-| 1K formats | 0 B | 93.75 KB |
-| 1M formats | 0 B | 91.55 MB |
+ // BenchmarkDotNet results (.NET 10.0 X64 RyuJIT)
+| Method | Scenario / Input | Mean | Gen 0 | Allocated |
+|---------------------------|------------------|-----------|--------|-----------|
+| StandardScaled | Naive (999,499) | 78.33 ns | 0.0026 | 80 B |
+| ToHuman | Governed (999,499)| 172.79 ns| 0.0024 | 56 B |
+| ToHuman (Span) | Governed (999,499)| 152.09 ns| 0.0007 | 24 B |
+| TryParse | $1.50M | 50.86 ns | - | 0 B |
+| ToHumanBytes | 1024 Bytes | 56.62 ns | 0.0013 | 40 B |
+| ToHumanWords | 1234.56 | 322.15 ns | 0.0186 | 560 B |
+| ToRoman | 2024 | 31.79 ns | 0.0013 | 40 B |
- HumanNumbers consistently outperforms standard formatting by 4x while using zero memory.
- The performance advantage increases with dataset size due to reduced GC pressure.
+ While HumanNumbers handles complex threshold and rounding logic that naive implementations often miss, it does so with a smaller memory footprint—reducing allocations from 80 B down to 56 B for standard formatting, and down to 24 B for Span-based paths. Parsing operations (TryParse) are entirely allocation-free (0 B).
- Dive into real-world examples and implementation patterns: + We are actively developing real-world examples and implementation patterns. The following sample projects will be available in the GitHub repository soon:
+- Zero-allocation patterns for high-throughput scenarios. + Low-Allocation patterns for high-throughput scenarios.
- All contributions should maintain the library's core principles: zero-allocation performance, + All contributions should maintain the library's core principles: Low-Allocation performance, never-throw safety, and clean API design. Check the contributing guidelines for detailed requirements and the development setup process.
@@ -1805,7 +1801,7 @@ public class FinancialController : ControllerBaseHappy Formatting!
- Join thousands of developers using HumanNumbers in production applications worldwide. + Join developers using HumanNumbers in production applications worldwide.
HumanNumbers
- is optimized for zero-allocation hot paths using Span<char>