Skip to content
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

WIP Benchmarks between nuget versions #310

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
7 changes: 7 additions & 0 deletions Lucene.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{4D0ED7D9
src\dotnet\Lucene.Net.CodeAnalysis\tools\install.ps1 = src\dotnet\Lucene.Net.CodeAnalysis\tools\install.ps1
src\dotnet\Lucene.Net.CodeAnalysis\tools\uninstall.ps1 = src\dotnet\Lucene.Net.CodeAnalysis\tools\uninstall.ps1
EndProjectSection
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Tests.BenchmarkDotNet", "src\Lucene.Net.Tests.BenchmarkDotNet\Lucene.Net.Tests.BenchmarkDotNet.csproj", "{0C476146-411E-4C94-8A59-726A5F982A89}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lucene.Net.Tests.AllProjects", "src\Lucene.Net.Tests.AllProjects\Lucene.Net.Tests.AllProjects.csproj", "{9880B87D-8D14-476B-B093-9C3AA0DA8B24}"
EndProject
Expand Down Expand Up @@ -491,6 +492,12 @@ Global
{E71152A0-48CC-4334-981F-F5FBFFA50891}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E71152A0-48CC-4334-981F-F5FBFFA50891}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E71152A0-48CC-4334-981F-F5FBFFA50891}.Release|Any CPU.Build.0 = Release|Any CPU
{8988CDA4-8420-4BEE-869A-66825055EED2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8988CDA4-8420-4BEE-869A-66825055EED2}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{0C476146-411E-4C94-8A59-726A5F982A89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C476146-411E-4C94-8A59-726A5F982A89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C476146-411E-4C94-8A59-726A5F982A89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C476146-411E-4C94-8A59-726A5F982A89}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
65 changes: 65 additions & 0 deletions src/Lucene.Net.Tests.BenchmarkDotNet/BuildConfigurations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System.Collections.Generic;

namespace Lucene.Net.Tests.BenchmarkDotNet
{
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

public static class BuildConfigurations
{
public static IList<BuildConfiguration> Configs = new List<BuildConfiguration>
{
//new BuildConfiguration { PackageVersion = "4.8.0-beta00005" },
//new BuildConfiguration { PackageVersion = "4.8.0-beta00006" },
//new BuildConfiguration { PackageVersion = "4.8.0-beta00007" },
//new BuildConfiguration { PackageVersion = "4.8.0-beta00008" },
//new BuildConfiguration { PackageVersion = "4.8.0-beta00009" },
//new BuildConfiguration { PackageVersion = "4.8.0-beta00010" },
//new BuildConfiguration { PackageVersion = "4.8.0-beta00011" },
//new BuildConfiguration { PackageVersion = "4.8.0-beta00012" },
//new BuildConfiguration { PackageVersion = "4.8.0-beta00013" },
new BuildConfiguration { PackageVersion = "4.8.0-beta00014" },
new BuildConfiguration { PackageVersion = "4.8.0-beta00015" },
new BuildConfiguration { PackageVersion = "4.8.0-beta00016" },
new BuildConfiguration { PackageVersion = "4.8.0-beta00017" },
//new BuildConfiguration { CustomConfigurationName = "LocalBuild", Id = "LocalBuild" }, // NOTE: This functions, but for some reason is less performant than testing a NuGet package
};
}

public class BuildConfiguration
{
private string id;

/// <summary>
/// NuGet package version. May be on a NuGet feed or a local directory configured as a feed.
/// </summary>
public string PackageVersion { get; set; }

public string CustomConfigurationName { get; set; }

public string Id
{
get
{
if (id is null)
return PackageVersion;
return id;
}
set => id = value;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using Lucene.Net.Demo.Facet;

namespace Lucene.Net.Tests.BenchmarkDotNet
{
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

[MemoryDiagnoser]
[Config(typeof(Config))]
public class FacetsAssociationsBenchmarks
{
private class Config : ManualConfig
{
public Config()
{
var baseJob = Job.MediumRun;

for (int i = 0; i < BuildConfigurations.Configs.Count; i++)
{
var config = BuildConfigurations.Configs[i];
if (string.IsNullOrEmpty(config.CustomConfigurationName))
{
AddJob(baseJob.WithNuGet("Lucene.Net.Analysis.Common", config.PackageVersion)
.WithNuGet("Lucene.Net.Facet", config.PackageVersion)
.WithId($"{i:000}-{config.Id}"));
}
else
{
AddJob(baseJob.WithCustomBuildConfiguration(config.CustomConfigurationName)
.WithId($"{i:000}-{config.Id}"));
}
}
}
}

public static readonly AssociationsFacetsExample example = new AssociationsFacetsExample();

[Benchmark]
public void RunSumAssociations() => example.RunSumAssociations();

[Benchmark]
public void RunDrillDown() => example.RunDrillDown();
}
}
68 changes: 68 additions & 0 deletions src/Lucene.Net.Tests.BenchmarkDotNet/FacetsDistanceBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using Lucene.Net.Demo.Facet;

namespace Lucene.Net.Tests.BenchmarkDotNet
{
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

[MemoryDiagnoser]
[Config(typeof(Config))]
public class FacetsDistanceBenchmarks
{
private class Config : ManualConfig
{
public Config()
{
var baseJob = Job.MediumRun;

for (int i = 0; i < BuildConfigurations.Configs.Count; i++)
{
var config = BuildConfigurations.Configs[i];
if (string.IsNullOrEmpty(config.CustomConfigurationName))
{
AddJob(baseJob.WithNuGet("Lucene.Net.Analysis.Common", config.PackageVersion)
.WithNuGet("Lucene.Net.Expressions", config.PackageVersion)
.WithNuGet("Lucene.Net.Facet", config.PackageVersion)
.WithId($"{i:000}-{config.Id}"));
}
else
{
AddJob(baseJob.WithCustomBuildConfiguration(config.CustomConfigurationName)
.WithId($"{i:000}-{config.Id}"));
}
}
}
}

public static readonly DistanceFacetsExample example = new DistanceFacetsExample();

[GlobalSetup]
public void GlobalSetup() => example.Index();

[GlobalCleanup]
public void GlobalTearDown() => example.Dispose();

[Benchmark]
public void Search() => example.Search();

[Benchmark]
public void DrillDown() => example.DrillDown(DistanceFacetsExample.TWO_KM);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using Lucene.Net.Demo.Facet;

namespace Lucene.Net.Tests.BenchmarkDotNet
{
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

[MemoryDiagnoser]
[Config(typeof(Config))]
public class FacetsExpressionAggregationBenchmarks
{
private class Config : ManualConfig
{
public Config()
{
var baseJob = Job.MediumRun;

for (int i = 0; i < BuildConfigurations.Configs.Count; i++)
{
var config = BuildConfigurations.Configs[i];
if (string.IsNullOrEmpty(config.CustomConfigurationName))
{
AddJob(baseJob.WithNuGet("Lucene.Net.Analysis.Common", config.PackageVersion)
.WithNuGet("Lucene.Net.Expressions", config.PackageVersion)
.WithNuGet("Lucene.Net.Facet", config.PackageVersion)
.WithId($"{i:000}-{config.Id}"));
}
else
{
AddJob(baseJob.WithCustomBuildConfiguration(config.CustomConfigurationName)
.WithId($"{i:000}-{config.Id}"));
}
}
}
}

public static readonly ExpressionAggregationFacetsExample example = new ExpressionAggregationFacetsExample();

[Benchmark]
public void RunSearch() => example.RunSearch();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using Lucene.Net.Demo.Facet;

namespace Lucene.Net.Tests.BenchmarkDotNet
{
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

[MemoryDiagnoser]
[Config(typeof(Config))]
public class FacetsMultiCategoryListsBenchmarks
{
private class Config : ManualConfig
{
public Config()
{
var baseJob = Job.MediumRun;

for (int i = 0; i < BuildConfigurations.Configs.Count; i++)
{
var config = BuildConfigurations.Configs[i];
if (string.IsNullOrEmpty(config.CustomConfigurationName))
{
AddJob(baseJob.WithNuGet("Lucene.Net.Analysis.Common", config.PackageVersion)
.WithNuGet("Lucene.Net.Facet", config.PackageVersion)
.WithId($"{i:000}-{config.Id}"));
}
else
{
AddJob(baseJob.WithCustomBuildConfiguration(config.CustomConfigurationName)
.WithId($"{i:000}-{config.Id}"));
}
}
}
}

public static readonly MultiCategoryListsFacetsExample example = new MultiCategoryListsFacetsExample();

[Benchmark]
public void RunSearch() => example.RunSearch();
}
}
Loading
Loading