Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/PerformanceTests/Program.cs @ 10200

Last change on this file since 10200 was 10200, checked in by ascheibe, 11 years ago

#1886

  • moved lrs code into analyzer project
  • added lrs performance test
  • moved performance tests into an own project
  • don't use 64 bit number format of lrs as it does not work correctly
File size: 2.0 KB
Line 
1using System;
2using System.Diagnostics;
3using System.Linq;
4using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers;
5
6namespace PerformanceTests {
7  class Program {
8    static void Main(string[] args) {
9      TestVolCalc();
10    }
11
12    public static void TestVolCalc() {
13      int dim = 4;
14      int size = 20;
15      var data = CreateRandomData(size, dim);
16      var dataList = data.ToList();
17      Stopwatch watch = new Stopwatch();
18
19
20      //calculate convex hull
21      watch.Start();
22      var convexHull = LPHull.Calculate(data);
23      watch.Stop();
24      Console.WriteLine("Convex hull calculation took : " + watch.Elapsed.TotalSeconds + " seconds.");
25
26
27      //calculate volume of convex hull
28      watch.Start();
29      double volume = ConvexHullMeasures.CalculateVolumeNew(convexHull);
30      watch.Stop();
31      Console.WriteLine("Volume calculation of convex hull took : " + watch.Elapsed.TotalSeconds + " seconds.");
32      Console.WriteLine("Volume of convex hull is: " + volume);
33
34
35      //do volume calculation from the whole data set
36      watch.Start();
37      volume = ConvexHullMeasures.CalculateVolumeNew(dataList);
38      watch.Stop();
39      Console.WriteLine("Volume calculation of whole data set took : " + watch.Elapsed.TotalSeconds + " seconds.");
40      Console.WriteLine("Volume of whole data is: " + volume);
41
42
43      //do volume calculation with lrs
44      watch.Start();
45      volume = LiblrsWrapper.CalculateVolume(dataList);
46      watch.Stop();
47      Console.WriteLine("Volume calculation of whole data set with lrs took : " + watch.Elapsed.TotalSeconds + " seconds.");
48      Console.WriteLine("Volume of whole data with lrs is: " + volume);
49    }
50
51    private static double[][] CreateRandomData(int n, int m) {
52      double[][] result = new double[n][];
53      Random rand = new Random();
54
55      for (int i = 0; i < n; i++) {
56        result[i] = new double[m];
57        for (int j = 0; j < m; j++) {
58          result[i][j] = (double)rand.Next(1, 60);
59        }
60      }
61      return result;
62    }
63  }
64}
Note: See TracBrowser for help on using the repository browser.