|
using BenchmarkDotNet.Attributes; |
|
using BenchmarkDotNet.Attributes.Columns; |
|
using BenchmarkDotNet.Attributes.Jobs; |
|
using System; |
|
|
|
namespace Bench |
|
{ |
|
[CoreJob] |
|
[MeanColumn, MinColumn, MaxColumn] |
|
[MemoryDiagnoser] |
|
public class TypeBench |
|
{ |
|
[Benchmark] |
|
public Type GenericsTypeFullNameWithAssemblyDetail() |
|
{ |
|
return Type.GetType(@"System.Collections.Generic.Dictionary`2[ |
|
[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e], |
|
[System.Collections.Generic.List`1[ |
|
[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e] |
|
], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], |
|
System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"); |
|
} |
|
|
|
[Benchmark] |
|
public Type GenericsTypeFullNameWithAssembly() |
|
{ |
|
return Type.GetType(@"System.Collections.Generic.Dictionary`2[ |
|
[System.String, System.Private.CoreLib], |
|
[System.Collections.Generic.List`1[[System.String, System.Private.CoreLib]], System.Private.CoreLib]], |
|
System.Private.CoreLib"); |
|
} |
|
|
|
[Benchmark] |
|
public Type GenericsTypeFullName() |
|
{ |
|
return Type.GetType(@"System.Collections.Generic.Dictionary`2[[System.String],[System.Collections.Generic.List`1[[System.String]]]]"); |
|
} |
|
|
|
[Benchmark] |
|
public Type TypeFullNameWithAssemblyDetail() |
|
{ |
|
return Type.GetType("System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"); |
|
} |
|
|
|
[Benchmark] |
|
public Type TypeFullNameWithAssembly() |
|
{ |
|
return Type.GetType("System.String, System.Private.CoreLib"); |
|
} |
|
|
|
[Benchmark] |
|
public Type TypeFullName() |
|
{ |
|
return Type.GetType("System.String"); |
|
} |
|
} |
|
} |