MorseSharp v4.0.0
Fluent API design
- Reorganized the MorseSharp library to introduce a fluent API structure.
- All Morse code conversions, including decoding, encoding, audio generation, and light blinking, are now conveniently accessible through a single Morse singleton class.
- Simplified the usage by providing a fluent interface for a smoother and more intuitive experience.
Light Support 🔦
MorseSharp now can generate lights, by using ToLight
then set the option, finally subscribe to the async DoBlinks
's method Action<bool>
delegate parameter:
Morse.GetConverter()
.ForLanguage(Language.English)
.ToLight(".... ..")
.SetBlinkerOptions(20, 25)
.DoBlinks((hasToBlink) => { });
Performance 🚀
One of the main focus of this release was tuning the performance:
- Significantly improved performance by implementing ref structs and utilizing Span.
- Introduced pooling mechanisms to enhance memory management, resulting in more efficient resource utilization.
- CommunityToolkit SpanOnwer, ListPool were used.
Benchmarks
MorseSharp v3.2.0
BenchmarkDotNet v0.13.10, Windows 11 (10.0.22621.2715/22H2/2022Update/SunValley2)
Intel Core i7-9750H CPU 2.60GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK 7.0.102
[Host] : .NET 7.0.14 (7.0.1423.51910), X64 RyuJIT AVX2 [AttachedDebugger]
DefaultJob : .NET 7.0.14 (7.0.1423.51910), X64 RyuJIT AVX2
Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated |
---|---|---|---|---|---|---|
ToMorse | 1.224 μs | 0.0292 μs | 0.0841 μs | 0.7706 | 0.0095 | 4.73 KB |
ToText | 1.335 μs | 0.0265 μs | 0.0735 μs | 0.8144 | 0.0095 | 5 KB |
ToAudio | 595.634 μs | 11.8373 μs | 14.0914 μs | 132.8125 | 26.3672 | 817 KB |
MorseSharp v4.0.0
BenchmarkDotNet v0.13.9+228a464e8be6c580ad9408e98f18813f6407fb5a, Windows 11 (10.0.22621.2715/22H2/2022Update/SunValley2)
Intel Core i7-9750H CPU 2.60GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2 [AttachedDebugger]
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
Method | Mean | Error | StdDev | Gen0 | Allocated |
---|---|---|---|---|---|
ToMorse | 215.8 ns | 2.24 ns | 1.98 ns | 0.0088 | 56 B |
ToText | 362.6 ns | 5.98 ns | 5.30 ns | 0.0153 | 96 B |
ToAudioBytes | 87,060.7 ns | 1,145.76 ns | 956.76 ns | - | 249 B |