-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Added Benchmark performance tests for wikidetoxData #820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8a09798
added some performance tests
Anipik 8904a31
added word embeding performancetests
Anipik 3e76854
Build Failure Corrected
Anipik abf22a7
feedback addressed
Anipik 78ff767
Casing, static fields removed and excpetion corrected
Anipik 80e6585
s_ removed
Anipik d540422
Names changed
Anipik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using Microsoft.ML.Runtime; | ||
using Microsoft.ML.Runtime.Data; | ||
using Microsoft.ML.Runtime.RunTests; | ||
using Microsoft.ML.Runtime.Tools; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace Microsoft.ML.Benchmarks | ||
{ | ||
// Adding this class to not print anything to the console. | ||
// This is required for the current version of BenchmarkDotNet | ||
internal class EmptyWriter : TextWriter | ||
{ | ||
internal static readonly EmptyWriter Instance = new EmptyWriter(); | ||
public override Encoding Encoding => null; | ||
} | ||
|
||
public class BigramAndTrigramBenchmark | ||
{ | ||
private string _dataPath_Wiki; | ||
private string _modelPath_Wiki; | ||
|
||
[GlobalSetup(Targets = new string[] { | ||
nameof(CV_Multiclass_WikiDetox_BigramsAndTrichar_OVAAveragedPerceptron), | ||
nameof(CV_Multiclass_WikiDetox_BigramsAndTrichar_LightGBMMulticlass) })] | ||
public void SetupTrainingSpeedTests() | ||
{ | ||
_dataPath_Wiki = Path.GetFullPath(TestDatasets.WikiDetox.trainFilename); | ||
|
||
if (!File.Exists(_dataPath_Wiki)) | ||
{ | ||
throw new FileNotFoundException($"Could not find {_dataPath_Wiki} Please ensure you have run 'build.cmd -- /t:DownloadExternalTestFiles /p:IncludeBenchmarkData=true' from the root"); | ||
} | ||
} | ||
|
||
[GlobalSetup(Target = nameof(Test_Multiclass_WikiDetox_BigramsAndTrichar_OVAAveragedPerceptron))] | ||
public void SetupScoringSpeedTests() | ||
{ | ||
SetupTrainingSpeedTests(); | ||
_modelPath_Wiki = Path.Combine(Directory.GetCurrentDirectory(), @"WikiModel.zip"); | ||
string cmd = @"CV k=5 data=" + _dataPath_Wiki + " loader=TextLoader{quote=- sparse=- col=Label:R4:0 col=rev_id:TX:1 col=comment:TX:2 col=logged_in:BL:4 col=ns:TX:5 col=sample:TX:6 col=split:TX:7 col=year:R4:3 header=+} xf=Convert{col=logged_in type=R4} xf=CategoricalTransform{col=ns} xf=TextTransform{col=FeaturesText:comment wordExtractor=NGramExtractorTransform{ngram=2}} xf=Concat{col=Features:FeaturesText,logged_in,ns} tr=OVA{p=AveragedPerceptron{iter=10}} out={" + _modelPath_Wiki + "}"; | ||
using (var tlc = new TlcEnvironment(verbose: false, sensitivity: MessageSensitivity.None, outWriter: EmptyWriter.Instance)) | ||
{ | ||
Maml.MainCore(tlc, cmd, alwaysPrintStacktrace: false); | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void CV_Multiclass_WikiDetox_BigramsAndTrichar_OVAAveragedPerceptron() | ||
{ | ||
string cmd = @"CV k=5 data=" + _dataPath_Wiki + " loader=TextLoader{quote=- sparse=- col=Label:R4:0 col=rev_id:TX:1 col=comment:TX:2 col=logged_in:BL:4 col=ns:TX:5 col=sample:TX:6 col=split:TX:7 col=year:R4:3 header=+} xf=Convert{col=logged_in type=R4} xf=CategoricalTransform{col=ns} xf=TextTransform{col=FeaturesText:comment wordExtractor=NGramExtractorTransform{ngram=2}} xf=Concat{col=Features:FeaturesText,logged_in,ns} tr=OVA{p=AveragedPerceptron{iter=10}}"; | ||
using (var tlc = new TlcEnvironment(verbose: false, sensitivity: MessageSensitivity.None, outWriter: EmptyWriter.Instance)) | ||
{ | ||
Maml.MainCore(tlc, cmd, alwaysPrintStacktrace: false); | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void CV_Multiclass_WikiDetox_BigramsAndTrichar_LightGBMMulticlass() | ||
{ | ||
string cmd = @"CV k=5 data=" + _dataPath_Wiki + " loader=TextLoader{quote=- sparse=- col=Label:R4:0 col=rev_id:TX:1 col=comment:TX:2 col=logged_in:BL:4 col=ns:TX:5 col=sample:TX:6 col=split:TX:7 col=year:R4:3 header=+} xf=Convert{col=logged_in type=R4} xf=CategoricalTransform{col=ns} xf=TextTransform{col=FeaturesText:comment wordExtractor=NGramExtractorTransform{ngram=2}} xf=Concat{col=Features:FeaturesText,logged_in,ns} tr=LightGBMMulticlass{}"; | ||
using (var tlc = new TlcEnvironment(verbose: false, sensitivity: MessageSensitivity.None, outWriter: EmptyWriter.Instance)) | ||
{ | ||
Maml.MainCore(tlc, cmd, alwaysPrintStacktrace: false); | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void Test_Multiclass_WikiDetox_BigramsAndTrichar_OVAAveragedPerceptron() | ||
{ | ||
// This benchmark is profiling bulk scoring speed and not training speed. | ||
string modelpath = Path.Combine(Directory.GetCurrentDirectory(), @"WikiModel.fold000.zip"); | ||
string cmd = @"Test data=" + _dataPath_Wiki + " in=" + modelpath; | ||
using (var tlc = new TlcEnvironment(verbose: false, sensitivity: MessageSensitivity.None, outWriter: EmptyWriter.Instance)) | ||
{ | ||
Maml.MainCore(tlc, cmd, alwaysPrintStacktrace: false); | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.