fix(core): Streamlines text encoding (#407)

- [X] Streamlines text encoding
This commit is contained in:
Kamron Batman 2021-01-13 18:56:32 -08:00 committed by GitHub
parent 5631c1da6d
commit 211c2ba8ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 274 additions and 137 deletions

View file

@ -0,0 +1,32 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Server.Text;
namespace Benchmarks.BenchmarkText
{
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.NetCoreApp50)]
public class BenchmarkTextEncoding
{
private const string text =
"This is supposed to be a really long text Ƞă¼ÖƄŭȘú😅¥♓ǵDƤĂ😋ġǁ⚕😐'ƿī😪_l" +
"This is supposed to be a really long text Ƞă¼ÖƄŭȘú😅¥♓ǵDƤĂ😋ġǁ⚕😐'ƿī😪_l" +
"This is supposed to be a really long text Ƞă¼ÖƄŭȘú😅¥♓ǵDƤĂ😋ġǁ⚕😐'ƿī😪_l" +
"This is supposed to be a really long text Ƞă¼ÖƄŭȘú😅¥♓ǵDƤĂ😋ġǁ⚕😐'ƿī😪_l" +
"This is supposed to be a really long text Ƞă¼ÖƄŭȘú😅¥♓ǵDƤĂ😋ġǁ⚕😐'ƿī😪_l";
[Benchmark]
public byte[] TestEncodingOldReturnBytes()
{
var bytes = TextEncoding.UTF8.GetBytes(text);
return bytes;
}
[Benchmark]
public byte[] TestEncodingNewReturnBytes()
{
var bytes = text.GetBytesUtf8();
return bytes;
}
}
}