@@ -17,17 +17,17 @@ namespace BenchmarkDotNet.Running
17
17
public static class BenchmarkRunner
18
18
{
19
19
[ PublicAPI ]
20
- public static Summary Run < T > ( IConfig config = null )
20
+ public static Summary Run < T > ( IConfig config = null , string [ ] args = null )
21
21
{
22
22
using ( DirtyAssemblyResolveHelper . Create ( ) )
23
- return RunWithExceptionHandling ( ( ) => RunWithDirtyAssemblyResolveHelper ( typeof ( T ) , config ) ) ;
23
+ return RunWithExceptionHandling ( ( ) => RunWithDirtyAssemblyResolveHelper ( typeof ( T ) , config , args ) ) ;
24
24
}
25
25
26
26
[ PublicAPI ]
27
- public static Summary Run ( Type type , IConfig config = null )
27
+ public static Summary Run ( Type type , IConfig config = null , string [ ] args = null )
28
28
{
29
29
using ( DirtyAssemblyResolveHelper . Create ( ) )
30
- return RunWithExceptionHandling ( ( ) => RunWithDirtyAssemblyResolveHelper ( type , config ) ) ;
30
+ return RunWithExceptionHandling ( ( ) => RunWithDirtyAssemblyResolveHelper ( type , config , args ) ) ;
31
31
}
32
32
33
33
[ PublicAPI ]
@@ -38,10 +38,10 @@ public static Summary Run(Type type, MethodInfo[] methods, IConfig config = null
38
38
}
39
39
40
40
[ PublicAPI ]
41
- public static Summary [ ] Run ( Assembly assembly , IConfig config = null )
41
+ public static Summary [ ] Run ( Assembly assembly , IConfig config = null , string [ ] args = null )
42
42
{
43
43
using ( DirtyAssemblyResolveHelper . Create ( ) )
44
- return RunWithExceptionHandling ( ( ) => RunWithDirtyAssemblyResolveHelper ( assembly , config ) ) ;
44
+ return RunWithExceptionHandling ( ( ) => RunWithDirtyAssemblyResolveHelper ( assembly , config , args ) ) ;
45
45
}
46
46
47
47
[ PublicAPI ]
@@ -73,16 +73,21 @@ public static Summary RunSource(string source, IConfig config = null)
73
73
}
74
74
75
75
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
76
- private static Summary RunWithDirtyAssemblyResolveHelper ( Type type , IConfig config )
77
- => BenchmarkRunnerClean . Run ( new [ ] { BenchmarkConverter . TypeToBenchmarks ( type , config ) } ) . Single ( ) ;
76
+ private static Summary RunWithDirtyAssemblyResolveHelper ( Type type , IConfig config , string [ ] args )
77
+ => ( args == null
78
+ ? BenchmarkRunnerClean . Run ( new [ ] { BenchmarkConverter . TypeToBenchmarks ( type , config ) } )
79
+ : new BenchmarkSwitcher ( new [ ] { type } ) . RunWithDirtyAssemblyResolveHelper ( args , config , false ) )
80
+ . Single ( ) ;
78
81
79
82
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
80
83
private static Summary RunWithDirtyAssemblyResolveHelper ( Type type , MethodInfo [ ] methods , IConfig config = null )
81
84
=> BenchmarkRunnerClean . Run ( new [ ] { BenchmarkConverter . MethodsToBenchmarks ( type , methods , config ) } ) . Single ( ) ;
82
85
83
86
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
84
- private static Summary [ ] RunWithDirtyAssemblyResolveHelper ( Assembly assembly , IConfig config = null )
85
- => BenchmarkRunnerClean . Run ( assembly . GetRunnableBenchmarks ( ) . Select ( type => BenchmarkConverter . TypeToBenchmarks ( type , config ) ) . ToArray ( ) ) ;
87
+ private static Summary [ ] RunWithDirtyAssemblyResolveHelper ( Assembly assembly , IConfig config , string [ ] args )
88
+ => args == null
89
+ ? BenchmarkRunnerClean . Run ( assembly . GetRunnableBenchmarks ( ) . Select ( type => BenchmarkConverter . TypeToBenchmarks ( type , config ) ) . ToArray ( ) )
90
+ : new BenchmarkSwitcher ( assembly ) . RunWithDirtyAssemblyResolveHelper ( args , config , false ) . ToArray ( ) ;
86
91
87
92
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
88
93
private static Summary [ ] RunWithDirtyAssemblyResolveHelper ( BenchmarkRunInfo [ ] benchmarkRunInfos )
@@ -126,4 +131,4 @@ private static Summary[] RunWithExceptionHandling(Func<Summary[]> run)
126
131
}
127
132
}
128
133
}
129
- }
134
+ }
0 commit comments