Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/benchmarks/micro/Serializers/Binary_FromStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace MicroBenchmarks.Serializers
{
#pragma warning disable SYSLIB0011 // BinaryFormatter serialization is obsolete and should not be used.
[GenericTypeArguments(typeof(LoginViewModel))]
[GenericTypeArguments(typeof(Location))]
[GenericTypeArguments(typeof(IndexViewModel))]
Expand Down Expand Up @@ -84,4 +85,5 @@ public T MessagePack_()
[GlobalCleanup]
public void Cleanup() => memoryStream.Dispose();
}
#pragma warning restore SYSLIB0011
}
2 changes: 2 additions & 0 deletions src/benchmarks/micro/Serializers/Binary_ToStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace MicroBenchmarks.Serializers
{
#pragma warning disable SYSLIB0011 // BinaryFormatter serialization is obsolete and should not be used.
[GenericTypeArguments(typeof(LoginViewModel))]
[GenericTypeArguments(typeof(Location))]
[GenericTypeArguments(typeof(IndexViewModel))]
Expand Down Expand Up @@ -57,4 +58,5 @@ public void MessagePack_()
MessagePack.MessagePackSerializer.Serialize<T>(memoryStream, value);
}
}
#pragma warning restore SYSLIB0011
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace System.Runtime.Serialization.Formatters.Tests
{
#pragma warning disable SYSLIB0011 // BinaryFormatter serialization is obsolete and should not be used.
[BenchmarkCategory(Categories.Libraries, Categories.NoWASM)]
public class Perf_BinaryFormatter
{
Expand Down Expand Up @@ -47,4 +48,5 @@ public class Book
public string Id;
}
}
#pragma warning restore SYSLIB0011
}
59 changes: 58 additions & 1 deletion src/benchmarks/micro/libraries/System.Runtime/Perf.String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public string Remove_IntInt(string s, int i1, int i2)
[Arguments("dzsdzsDDZSDZSDZSddsz", 0)]
[Arguments("dzsdzsDDZSDZSDZSddsz", 7)]
[Arguments("dzsdzsDDZSDZSDZSddsz", 10)]
[Arguments("dzsdzsDDZSDZSDZSddsz", 19)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably will delete this change, so ignore it

public string Substring_Int(string s, int i)
=> s.Substring(i);

Expand Down Expand Up @@ -276,7 +277,63 @@ private static char getStringCharNoInline(string str, int index)
return str[index];
}
}


[BenchmarkCategory(Categories.Runtime, Categories.Libraries)]
[DisassemblyDiagnoser(maxDepth: 2, printSource: true, exportHtml: true, exportDiff: true)]
public class Perf_String_Substring_Int
{
const int _length = 16;
static readonly string _s = new string('a', _length);

[ParamsSource(nameof(GetStarts))]
public int Start { get; set; }

public static IEnumerable<int> GetStarts()
{
yield return 0;
yield return _length / 2;
yield return _length;
}

[Benchmark]
public void Substring() => _s.Substring(Start);
}

[BenchmarkCategory(Categories.Runtime, Categories.Libraries)]
[DisassemblyDiagnoser(maxDepth: 2, printSource: true, exportHtml: true, exportDiff: true)]
public class Perf_String_Substring_IntInt
{
const int _length = 16;
static readonly string _s = new string('a', _length);

[ParamsSource(nameof(GetSlices))]
public Sub Slice { get; set; }

public static IEnumerable<Sub> GetSlices()
{
for (int i = 0; i <= _length / 2; i++)
{
yield return new() { StartIndex = i, Length = i };
}
yield return new() { StartIndex = 0, Length = _length };
}

public class Sub
{
public int StartIndex { get; set; }
public int Length { get; set; }

public override string ToString() => $"I:{StartIndex,2} L:{Length,2}";
}

[Benchmark]
public void Substring()
{
var slice = Slice;
_s.Substring(slice.StartIndex, slice.Length);
}
}

public class StringArguments
{
public int Size { get; }
Expand Down