#region License Information
/* HeuristicLab
* Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using HeuristicLab.Algorithms.GeneticAlgorithm;
using HeuristicLab.Common;
using HeuristicLab.Optimization;
using HeuristicLab.Persistence.Default.Xml;
using HeuristicLab.Problems.TestFunctions;
using HeuristicLab.SequentialEngine;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace HeuristicLab_33.Tests {
[TestClass]
public class CollectObjectGraphTest {
private TestContext testContextInstance;
public TestContext TestContext {
get { return testContextInstance; }
set { testContextInstance = value; }
}
[TestMethod]
[DeploymentItem(@"GA_SymbReg.hl")]
public void CollectGASample() {
GeneticAlgorithm ga = (GeneticAlgorithm)XmlParser.Deserialize("GA_SymbReg.hl");
Stopwatch watch = new Stopwatch();
watch.Start();
for (int i = 0; i < 1; i++)
ga.GetObjectGraphObjects().Count();
watch.Stop();
var objects = ga.GetObjectGraphObjects().ToList();
TestContext.WriteLine("Time elapsed {0}", watch.Elapsed);
TestContext.WriteLine("Objects discovered: {0}", objects.Count());
TestContext.WriteLine("HL objects discovered: {0}", objects.Where(o => o.GetType().Namespace.StartsWith("HeuristicLab")).Count());
TestContext.WriteLine("");
Dictionary> objs = new Dictionary>();
foreach (object o in objects) {
if (!objs.ContainsKey(o.GetType()))
objs.Add(o.GetType(), new List