-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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,87 @@ | ||
// Copyright 2012-2020 Dmytro Kyshchenko | ||
// | ||
// Licensed 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. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using xFunc.Maths.Analyzers.TypeAnalyzers; | ||
using xFunc.Maths.Expressions; | ||
using xFunc.Maths.Expressions.Matrices; | ||
using xFunc.Maths.Expressions.Statistical; | ||
|
||
namespace xFunc.Benchmark.Benchmarks | ||
{ | ||
public class TypeAnalyzerBenchmark | ||
{ | ||
private TypeAnalyzer analyzer; | ||
|
||
private GCD gcd; | ||
private GCD gcdUndefined; | ||
|
||
private Matrix matrix; | ||
|
||
private Count count; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
analyzer = new TypeAnalyzer(); | ||
|
||
gcd = new GCD(new IExpression[] | ||
{ | ||
new Number(2), new Number(4), new Number(6), new Number(8), | ||
new Number(2), new Number(4), new Number(6), new Number(8), | ||
new Number(2), new Number(4), new Number(6), new Number(8), | ||
new Number(2), new Number(4), new Number(6), new Number(8), | ||
}); | ||
gcdUndefined = new GCD(new IExpression[] | ||
{ | ||
new Number(2), new Number(4), new Number(6), new Number(8), | ||
new Number(2), new Number(4), new Number(6), new Number(8), | ||
Variable.X, new Number(4), new Number(6), new Number(8), | ||
new Number(2), new Number(4), new Number(6), new Number(8), | ||
}); | ||
|
||
matrix = new Matrix(new[] | ||
{ | ||
new Vector(new IExpression[] { new Number(2), new Number(2), new Number(2), }), | ||
new Vector(new IExpression[] { new Number(2), new Number(2), new Number(2), }), | ||
new Vector(new IExpression[] { new Number(2), new Number(2), new Number(2), }), | ||
}); | ||
|
||
count = new Count(new IExpression[] | ||
{ | ||
new Number(2), new Number(2), new Number(2), new Number(2), | ||
new Number(2), new Number(2), new Number(2), new Number(2), | ||
new Number(2), new Number(2), new Number(2), new Number(2), | ||
new Number(2), new Number(2), new Number(2), new Number(2), | ||
}); | ||
} | ||
|
||
[Benchmark] | ||
public ResultType GCD() | ||
=> gcd.Analyze(analyzer); | ||
|
||
[Benchmark] | ||
public ResultType GCDUndefined() | ||
=> gcdUndefined.Analyze(analyzer); | ||
|
||
[Benchmark] | ||
public ResultType Matrix() | ||
=> matrix.Analyze(analyzer); | ||
|
||
[Benchmark] | ||
public ResultType Count() | ||
=> count.Analyze(analyzer); | ||
} | ||
} |