- Timestamp:
- 09/13/13 12:10:37 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs
r9955 r9956 111 111 TestArithmeticGrammarPerformance(new SymbolicDataAnalysisExpressionTreeLinearInterpreter(), 12.5e6); 112 112 } 113 114 [TestMethod]115 [TestCategory("Problems.DataAnalysis.Symbolic")]116 [TestProperty("Time", "long")]117 public void ExpressionTreeInterpreterTestArithmeticGrammarPerformance() {118 TestArithmeticGrammarPerformance(new ExpressionTreeInterpreter(), 12.5e6);119 }120 121 [TestMethod]122 [TestCategory("Problems.DataAnalysis.Symbolic")]123 [TestProperty("Time", "long")]124 public void ExpressionTreeInterpreterTestCompilationPerformance() {125 var twister = new MersenneTwister(31415);126 var dataset = Util.CreateRandomDataset(twister, Rows, Columns);127 var grammar = new ArithmeticExpressionGrammar();128 //grammar.Symbols.OfType<Variable>().First().Enabled = false;129 grammar.MaximumFunctionArguments = 0;130 grammar.MaximumFunctionDefinitions = 0;131 grammar.MinimumFunctionArguments = 0;132 grammar.MinimumFunctionDefinitions = 0;133 134 var trees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1, 100, 0, 0).ToArray();135 foreach (SymbolicExpressionTree tree in trees)136 Util.InitTree(tree, twister, new List<string>(dataset.VariableNames));137 138 139 var data = dataset.DoubleVariables.ToDictionary(key => key, v => (IList<double>)dataset.GetReadOnlyDoubleValues(v));140 var param = Expression.Parameter(typeof(int), "row");141 142 Stopwatch watch = new Stopwatch();143 int repetitions = 3;144 145 long nNodes = trees.Aggregate<ISymbolicExpressionTree, long>(0, (current, t) => current + t.Length);146 147 for (int rep = 0; rep < repetitions; rep++) {148 watch.Start();149 foreach (ISymbolicExpressionTree t in trees) {150 var exp = ExpressionTreeInterpreter.CreateExpression(t.Root.GetSubtree(0).GetSubtree(0), data, param);151 while (exp.CanReduce) exp = exp.Reduce();152 var function = Expression.Lambda<Func<int, double>>(exp, param).Compile();153 function(0);154 }155 watch.Stop();156 }157 Console.WriteLine("Random tree compilation performance of expression tree interpreter: " + Environment.NewLine +158 watch.ElapsedMilliseconds + "ms " + Environment.NewLine +159 Util.NodesPerSecond(nNodes * repetitions, watch) + " nodes/sec" + Environment.NewLine +160 Util.NodesPerSecond(trees.Length * repetitions, watch) + " trees/sec"161 );162 163 }164 165 113 166 114 private void TestTypeCoherentGrammarPerformance(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, double nodesPerSecThreshold) {
Note: See TracChangeset
for help on using the changeset viewer.