Skip to content

Commit

Permalink
Merge pull request #9 from markcastle/feature/updated_readme
Browse files Browse the repository at this point in the history
Updated: Readme
  • Loading branch information
markcastle committed Apr 22, 2023
2 parents bf4a637 + 70877ca commit beaad6e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 146 deletions.
1 change: 1 addition & 0 deletions CaseConverter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt
ProjectSection(SolutionItems) = preProject
.appveyor.yml = .appveyor.yml
.github\workflows\build_and_publish.yml = .github\workflows\build_and_publish.yml
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CaseConverter.Benchmarks", "CaseConverter.Benchmarks\CaseConverter.Benchmarks.csproj", "{46C82C0F-22D2-4128-808B-3FDC5CB496D9}"
Expand Down
3 changes: 2 additions & 1 deletion CaseConverter/CaseConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<Authors>Mark Castle</Authors>
<Version>2.0.0</Version>
<Version>2.0.1</Version>
<Company>Captive Reality Ltd</Company>
<Copyright>© Captive Reality Ltd. All Rights Reserved.</Copyright>
<PackageLicenseFile>LICENCE</PackageLicenseFile>
Expand All @@ -17,6 +17,7 @@
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="..\README.md" Link="README.md" />
</ItemGroup>

<PropertyGroup>
Expand Down
141 changes: 0 additions & 141 deletions CaseConverter/README.md

This file was deleted.

68 changes: 64 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ dotnet CLI

```csharp

using CaseConverter;
using CaseConverter;

Console.WriteLine("Hello World!".ToCamelCase());
Console.WriteLine("Hello World!".ToCamelCase());
Console.WriteLine("Hello World!".ToSnakeCase());
Console.WriteLine("Hello World!".ToKebabCase());
Console.WriteLine("Hello World!".ToPascalCase());
Expand Down Expand Up @@ -57,13 +57,73 @@ Supplementary string extensions included:
- string.**FirstCharToLowerCase()** Convert the first character in a string to lower case.
- string.**FirstCharToUpperCase()** Convert the first character in a string to upper case.

I make no claims about the speed and efficiency of the included string extensions but welcome any pull requests that make improvements.

## Tests


We added a lot more tests in the latest version.

To run tests:

dotnet test

## Benchmarks

For the latest version we're working on improving performance and memory efficiency.. here is a comparison of the improvements.


Additional gains would likely be possible if we stopped targetting .NET STANDARD 2.0 and .NET STANDARD 2.1 and instead targetted .net 6+


#### ToPascalCase()

| Method | Mean | Error | StdDev | Gen0 | Allocated |
|--------------------------|------------|----------|----------|--------|-----------|
| ToPascalCaseBenchmark | 179.9 ns | 3.00 ns | 2.34 ns | 0.0315 | 264 B |
| ToPascalCaseBenchmarkOld | 2,269.5 ns | 43.25 ns | 36.12 ns | 0.4005 | 3352 B |

#### ToKebabCase()

| Method | Mean | Error | StdDev | Gen0 | Allocated |
|---------------------------|-------------|-----------|-----------|---------|-----------|
| ToKebabCaseBenchmark | 132.1 ns | 2.69 ns | 4.02 ns | 0.0324 | 272 B |
| ToKebabCaseBenchmarkOld | 1,423.1 ns | 27.69 ns | 27.19 ns | 0.0496 | 424 B |

#### ToTitleCase()

| Method | Mean | Error | StdDev | Gen0 | Allocated |
|------------------------ |----------|---------|---------|--------|-----------|
| ToTitleCaseBenchmark | 218.3 ns | 2.59 ns | 2.43 ns | 0.0200 | 168 B |
| ToTitleCaseBenchmarkOld | 225.8 ns | 3.26 ns | 3.05 ns | 0.0381 | 320 B |

#### ToCamelCase()

| Method | Mean | Error | StdDev | Gen0 | Allocated |
|------------------------ |----------|-----------|-----------|--------|-----------|
| ToCamelCaseBenchmark | 1.497 us | 0.0206 us | 0.0193 us | 0.1659 | 1.36 KB |
| ToCamelCaseOldBenchmark | 5.362 us | 0.0730 us | 0.0609 us | 0.4272 | 3.52 KB |

#### ToSnakeCase()

Wasn't able to improve it so left the original code intact.

| Method | Mean | Error | StdDev | Gen0 | Allocated |
|------------------------ |----------|-----------|-----------|--------|-----------|
| ToSnakeCaseBenchmark | 1.765 us | 0.0112 us | 0.0094 us | 0.1793 | 1.47 KB |

#### All Tests

| Method | Mean | Error | StdDev | Gen0 | Allocated |
|--------------------------- |-------------:|------------:|------------:|-------:|----------:|
| ToSnakeCaseBenchmark | 172.143 ns | 3.2836 ns | 3.2249 ns | 0.0343 | 288 B |
| ToCamelCaseBenchmark | 80.951 ns | 1.5001 ns | 1.3298 ns | 0.0200 | 168 B |
| ToKebabCaseBenchmark | 129.666 ns | 2.4154 ns | 2.6847 ns | 0.0324 | 272 B |
| ToPascalCaseBenchmark | 191.285 ns | 3.7843 ns | 3.8862 ns | 0.0315 | 264 B |
| ToTitleCaseBenchmark | 210.939 ns | 4.0187 ns | 4.3000 ns | 0.0200 | 168 B |
| ToTrainCaseBenchmark | 346.119 ns | 4.3459 ns | 4.0651 ns | 0.0639 | 536 B |
| IsAllUpperBenchmark | 5.075 ns | 0.0638 ns | 0.0533 ns | - | - |
| ReplaceWhitespaceBenchmark | 7,099.933 ns | 113.6132 ns | 100.7152 ns | 0.0839 | 728 B |

If you can suggest further improvements please get in touch or better still make the improvements and send us a PR :-)

## Contributing

Expand Down

0 comments on commit beaad6e

Please sign in to comment.