Skip to content

Commit

Permalink
update specs to 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ssg committed Nov 17, 2018
1 parent a18842b commit 3d4d446
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,49 @@ string text = ...
byte[] result = Base16.Decode(text); // decodes both upper and lowercase
```

### Stream Mode

Most encoding classes also support a stream mode that can work on streams, be it a network connection, a file
or whatever you want. They are ideal for handling arbitrarily large data as they don't consume memory
other than a small buffer when encoding or decoding. Their syntaxes are mostly identical.
Text encoding decoding is done through a `TextReader`/`TextWriter` and the rest is read through a `Stream`
interface. Here is a simple code that encodes a file to another file using Base85 encoding:

```csharp
using (var input = File.Open("somefile.bin"))
using (var output = File.Create("somefile.ascii85"))
using (var writer = new TextWriter(output)) // you can specify encoding here
{
Base85.Ascii85.Encode(input, writer);
}
```

Decode works similarly. Here is a Base32 file decoder:

```csharp
using (var input = File.Open("somefile.b32"))
using (var output = File.Create("somefile.bin"))
using (var reader = new TextReader(input)) // specify encoding here
{
Base32.Crockford.Decode(reader, output);
}
```

Benchmark Results
-----------------
Small buffer sizes are used (64 characters). They are closer to real life applications. Base58
performs really bad in decoding of larger buffer sizes, due to polynomial complexity of
numeric base conversions.

5,000,000 iterations
64 byte buffer for encoding
80 character string for decoding
64 byte buffer for encoding · 5,000,000 iterations · 80 character string for decoding

Implementation | Growth | Encode | Decode
----------------------------|--------|--------------------------|------------------
.NET Framework Base64 | 1.33x | 0.47 | 1.02
SimpleBase Base16 | 2x | 0.62 (1.3x slower) | 0.45 (2.3x faster! YAY!)
SimpleBase Base32 Crockford | 1.6x | 1.29 (2.7x slower) | 1.03 (about the same)
SimpleBase Base85 Z85 | 1.25x | 0.90 (1.9x slower) | 1.14 (1.1x slower)
SimpleBase Base58 | 1.38x | 30.78 (65.5x slower) | 27.24 (26.8x slower)
.NET Framework Base64 | 1.33x | 0.45 | 1.23
SimpleBase Base16 | 2x | 0.61 (1.4x slower) | 0.51 (2.4x faster! YAY!)
SimpleBase Base32 Crockford | 1.6x | 1.22 (2.7x slower) | 1.05 (1.2x faster! YAY!)
SimpleBase Base85 Z85 | 1.25x | 0.93 (2.1x slower) | 1.27 (about the same)
SimpleBase Base58 | 1.38x | 30.43 (67.9x slower) | 28.06 (22.8x slower)

Notes
-----
Expand Down
17 changes: 6 additions & 11 deletions SimpleBase.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>SimpleBase</id>
<version>1.6.1</version>
<version>1.7.0</version>
<title>SimpleBase</title>
<authors>Sedat Kapanoglu</authors>
<owners>Sedat Kapanoglu</owners>
Expand All @@ -14,19 +14,14 @@
<tags>base16 base32 base58 base85 ascii85 z85 hexadecimal bitcoin ripple flickr crockford extended hex rfc4648</tags>
<releaseNotes>
<![CDATA[
Breaking changes in this release:
- Use Span<T> instead of byte[], so callers can avoid some unnecessary memory copy operations
- Encoding functions don't throw exception on null input but return empty result instead
because of non-nullability of Span<T> types
New features:
- Stream-based methods for Base16/Base32/Base85 (Base58 isn't suitable by nature)
- New ReadOnlySpan<char> overloads to Decode functions
Improvements:
- Increased Base16 and Base32 encoding performance
Changes in 1.6.1:
- Properly include NuGet dependency to System.Memory
- Slightly better decoding performance on Base16 and Base32
]]>
</releaseNotes>
<dependencies>
Expand Down

0 comments on commit 3d4d446

Please sign in to comment.