fix(core): Streamlines text encoding (#407)
- [X] Streamlines text encoding
This commit is contained in:
parent
5631c1da6d
commit
211c2ba8ee
25 changed files with 274 additions and 137 deletions
32
Projects/Benchmarks/Benchmarks/Text/BenchmarkTextEncoding.cs
Normal file
32
Projects/Benchmarks/Benchmarks/Text/BenchmarkTextEncoding.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue