Skip to content

Commit

Permalink
Add more benchmark cases to catch performance edge-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Genbox committed Jan 21, 2024
1 parent 3a8c4e9 commit 527af30
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions benchmark/Sqids.Benchmarks/EncodeBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,20 @@ public class EncodeBenchmark
#endif

[Benchmark]
public string Encode() => _encoder.Encode(42);
public string EncodeSmall() => _encoder.Encode(42);

[Benchmark]
public IReadOnlyList<int> Decode() => _encoder.Decode("Jg");
public string EncodeBig() => _encoder.Encode(int.MaxValue);

[Benchmark]
public string EncodeMany() => _encoder.Encode(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

[Benchmark]
public IReadOnlyList<int> DecodeSmall() => _encoder.Decode("Jg");

[Benchmark]
public IReadOnlyList<int> DecodeBig() => _encoder.Decode("UKrsQ1F");

[Benchmark]
public IReadOnlyList<int> DecodeMany() => _encoder.Decode("hwB5vcCxfAyBnVKMtAaV");
}

0 comments on commit 527af30

Please sign in to comment.