fa8c822045
* version updates and fixes * fixed torch sharp test nuget * skipping test again * fixing typo * consolidating extensions versioning * fixed remote executor app |
||
---|---|---|
.. | ||
Harness | ||
Helpers | ||
Numeric | ||
Text | ||
BenchmarkBase.cs | ||
CacheDataViewBench.cs | ||
FeaturizeTextBench.cs | ||
HashBench.cs | ||
ImageClassificationBench.cs | ||
KMeansAndLogisticRegressionBench.cs | ||
Microsoft.ML.PerformanceTests.csproj | ||
PredictionEngineBench.cs | ||
Program.cs | ||
README.md | ||
RffTransform.cs | ||
ShuffleRowsBench.cs | ||
StochasticDualCoordinateAscentClassifierBench.cs | ||
TextLoaderBench.cs | ||
TextPredictionEngineCreation.cs |
README.md
ML.NET Benchmarks/Performance Tests
This project contains performance benchmarks.
Run the Performance Tests
Pre-requisite: In order to fetch dependencies which come through Git submodules the following command needs to be run before building:
git submodule update --init
Pre-requisite: On a clean repo with initialized submodules, build.cmd
at the root installs the right version of dotnet.exe and builds the solution. You need to build the solution in Release
.
build.cmd -configuration Release
-
Navigate to the performance tests directory (machinelearning\test\Microsoft.ML.PerformanceTests)
-
Run the benchmarks in Release:
build.cmd -configuration Release -performanceTest
Authoring new benchmarks
- The type which contains benchmark(s) has to be a public, non-sealed, non-static class.
- Put the initialization logic into a separate public method with
[GlobalSetup]
attribute. You can useTarget
property to make it specific for selected benchmark. Example:[GlobalSetup(Target = nameof(MakeIrisPredictions))]
. - Put the benchmarked code into a separate public method with
[Benchmark]
attribute. If the benchmark method computes some result, please return it from the benchmark. Harness will consume it to avoid dead code elimination. - If given benchmark is a Training benchmark, please apply
[Config(typeof(TrainConfig))]
to the class. It will tell BenchmarkDotNet to run the benchmark only once in a dedicated process to mimic the real-world scenario for training.
Examples:
public class NonTrainingBenchmark
{
[GlobalSetup(Target = nameof(TheBenchmark))]
public void Setup() { /* setup logic goes here */ }
[Benchmark]
public SomeResult TheBenchmark() { /* benchmarked code goes here */ }
}
[Config(typeof(TrainConfig))]
public class TrainingBenchmark
Running the BenchmarksProjectIsNotBroken
test
If your build is failing in the build machines, in the release configuration due to the BenchmarksProjectIsNotBroken
test failing,
you can debug this test locally by:
1- Building the solution in the release mode locally
build.cmd -configuration Release -performanceTest
2- Changing the configuration in Visual Studio from Debug -> Release
3- Changing the annotation in the BenchmarksProjectIsNotBroken
to replace BenchmarkTheory
with Theory
, as below.
[Theory]
[MemberData(nameof(GetBenchmarks))]
public void BenchmarksProjectIsNotBroken(Type type)
4- Restart Visual Studio 5- Proceed to running the tests normally from the Test Explorer view.