Changeset 6987


Ignore:
Timestamp:
11/14/11 14:12:51 (11 years ago)
Author:
spimming
Message:

#1659:

  • removed uncommented code
  • removed ‘Benchmark Name’ and ‘Benchmark Type’ from result collection
  • placed Getters/Setters after data members
  • added input validation
  • updated parameter description
Location:
branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/Benchmark.cs

    r6948 r6987  
    276276    private void CreateParameters() {
    277277      Parameters.Add(new ValueParameter<IntValue>("ChunkSize", "The size (MB) of the chunk array that gets generated", new IntValue(0)));
    278       Parameters.Add(new ValueParameter<DoubleValue>("TimeLimit", "The time limit (in minutes) for a benchmark run", new DoubleValue(0)));
     278      Parameters.Add(new ValueParameter<DoubleValue>("TimeLimit", "The time limit (in minutes) for a benchmark run. Zero means a fixed number of iterations", new DoubleValue(0)));
    279279    }
    280280
     
    292292          Parameters.Add(new ConstrainedValueParameter<IBenchmark>(paramName, values, values.First(a => a is IBenchmark)));
    293293        } else {
    294           // throw exception?
    295294          Parameters.Add(new ConstrainedValueParameter<IBenchmark>(paramName, values));
    296295        }
     
    363362        if (chunkSize > 0) {
    364363          BenchmarkAlgorithm.ChunkData = CreateDataChuck(chunkSize);
    365         }
    366         BenchmarkAlgorithm.TimeLimit = TimeSpan.FromMinutes(((DoubleValue)TimeLimitParameter.ActualValue).Value);
     364        } else if (chunkSize < 0) {
     365          throw new ArgumentException("ChunkSize must not be negativ.");
     366        }
     367        TimeSpan timelimit = TimeSpan.FromMinutes(((DoubleValue)TimeLimitParameter.ActualValue).Value);
     368        if (timelimit.TotalMilliseconds < 0) {
     369          throw new ArgumentException("TimeLimit must not be negativ. ");
     370        }
     371        BenchmarkAlgorithm.TimeLimit = timelimit;
    367372        BenchmarkAlgorithm.Run(cancellationToken, results);
    368373      }
    369374      catch (OperationCanceledException) {
    370         //Console.WriteLine(ex.ToString());
    371375      }
    372376      finally {
     
    411415        }
    412416      }
    413       values.Add("Benchmark Name", new StringValue(Name));
    414       values.Add("Benchmark Type", new StringValue(this.GetType().GetPrettyName()));
    415417    }
    416418
     
    426428      return chunk;
    427429    }
    428     /*
    429     private int[] CreateDataChuck(int megaBytes) {
    430       if (megaBytes <= 0) {
    431         throw new ArgumentException("MegaBytes must be greater than zero", "megaBytes");
    432       }
    433       int size = (megaBytes * 1020 * 1024) / sizeof(int);
    434       int[] data = new int[size];
    435       for (int i = 0; i < data.Length; i++) {
    436         data[i] = random.Next();
    437       }
    438       return data;
    439     }
    440     */
    441430
    442431    #region Events
  • branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/DhrystoneBenchmark.cs

    r6948 r6987  
    3636    [Storable]
    3737    private byte[][] chunk;
     38    public byte[][] ChunkData {
     39      get { return chunk; }
     40      set { chunk = value; }
     41    }
    3842
    3943    private TimeSpan timeLimit;
     44    public TimeSpan TimeLimit {
     45      get { return timeLimit; }
     46      set { timeLimit = value; }
     47    }
    4048
    4149    private bool stopBenchmark;
    4250
    4351    private CancellationToken cancellationToken;
     52
     53    public string ItemName {
     54      get { return ItemAttribute.GetName(this.GetType()); }
     55    }
     56
     57    public string ItemDescription {
     58      get { return ItemAttribute.GetDescription(this.GetType()); }
     59    }
     60
     61    public Version ItemVersion {
     62      get { return ItemAttribute.GetVersion(this.GetType()); }
     63    }
     64
     65    public Image ItemImage {
     66      get { return HeuristicLab.Common.Resources.VSImageLibrary.Event; }
     67    }
    4468
    4569    #region Benchmark Fields
     
    6791
    6892    private long Default_Number_Of_Runs = 10000000;
    69 
    70     #endregion
    71 
    72     #region Properties
    73 
    74     public byte[][] ChunkData {
    75       get { return chunk; }
    76       set { chunk = value; }
    77     }
    78 
    79     public TimeSpan TimeLimit {
    80       get { return timeLimit; }
    81       set { timeLimit = value; }
    82     }
    83 
    84     public string ItemName {
    85       get { return ItemAttribute.GetName(this.GetType()); }
    86     }
    87 
    88     public string ItemDescription {
    89       get { return ItemAttribute.GetDescription(this.GetType()); }
    90     }
    91 
    92     public Version ItemVersion {
    93       get { return ItemAttribute.GetVersion(this.GetType()); }
    94     }
    95 
    96     public Image ItemImage {
    97       get { return HeuristicLab.Common.Resources.VSImageLibrary.Event; }
    98     }
    9993
    10094    #endregion
  • branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/LinpackBenchmark.cs

    r6948 r6987  
    3636    [Storable]
    3737    private byte[][] chunk;
     38    public byte[][] ChunkData {
     39      get { return chunk; }
     40      set { chunk = value; }
     41    }
    3842
    3943    private TimeSpan timeLimit;
     44    public TimeSpan TimeLimit {
     45      get { return timeLimit; }
     46      set { timeLimit = value; }
     47    }
    4048
    4149    private bool stopBenchmark;
    4250
    4351    private CancellationToken cancellationToken;
     52
     53    public string ItemName {
     54      get { return ItemAttribute.GetName(this.GetType()); }
     55    }
     56
     57    public string ItemDescription {
     58      get { return ItemAttribute.GetDescription(this.GetType()); }
     59    }
     60
     61    public Version ItemVersion {
     62      get { return ItemAttribute.GetVersion(this.GetType()); }
     63    }
     64
     65    public Image ItemImage {
     66      get { return HeuristicLab.Common.Resources.VSImageLibrary.Event; }
     67    }
    4468
    4569    #region Benchmark Fields
     
    5478
    5579    private Stopwatch sw = new Stopwatch();
    56 
    57     #endregion
    58 
    59     #region Properties
    60 
    61     public byte[][] ChunkData {
    62       get { return chunk; }
    63       set { chunk = value; }
    64     }
    65 
    66     public TimeSpan TimeLimit {
    67       get { return timeLimit; }
    68       set { timeLimit = value; }
    69     }
    70 
    71     public string ItemName {
    72       get { return ItemAttribute.GetName(this.GetType()); }
    73     }
    74 
    75     public string ItemDescription {
    76       get { return ItemAttribute.GetDescription(this.GetType()); }
    77     }
    78 
    79     public Version ItemVersion {
    80       get { return ItemAttribute.GetVersion(this.GetType()); }
    81     }
    82 
    83     public Image ItemImage {
    84       get { return HeuristicLab.Common.Resources.VSImageLibrary.Event; }
    85     }
    8680
    8781    #endregion
     
    197191
    198192        executionTime += sw.Elapsed;
    199         if (timeLimit == null)
     193        if ((timeLimit == null) || (timeLimit.TotalMilliseconds == 0))
    200194          stopBenchmark = true;
    201195        else if (executionTime > timeLimit)
  • branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/WhetstoneAlgorithm.cs

    r6948 r6987  
    3636    [Storable]
    3737    private byte[][] chunk;
     38    public byte[][] ChunkData {
     39      get { return chunk; }
     40      set { chunk = value; }
     41    }
    3842
    3943    private TimeSpan timeLimit;
     44    public TimeSpan TimeLimit {
     45      get { return timeLimit; }
     46      set { timeLimit = value; }
     47    }
    4048
    4149    private bool stopBenchmark;
    4250
    4351    private CancellationToken cancellationToken;
     52
     53    public string ItemName {
     54      get { return ItemAttribute.GetName(this.GetType()); }
     55    }
     56
     57    public string ItemDescription {
     58      get { return ItemAttribute.GetDescription(this.GetType()); }
     59    }
     60
     61    public Version ItemVersion {
     62      get { return ItemAttribute.GetVersion(this.GetType()); }
     63    }
     64
     65    public Image ItemImage {
     66      get { return HeuristicLab.Common.Resources.VSImageLibrary.Event; }
     67    }
    4468
    4569    #region Benchmark Fields
     
    5579    private double[] e1 = new double[4];
    5680    private int i, j, k, l, n1, n2, n3, n4, n6, n7, n8, n9, n10, n11;
    57 
    58     #endregion
    59 
    60     #region Properties
    61 
    62     public byte[][] ChunkData {
    63       get { return chunk; }
    64       set { chunk = value; }
    65     }
    66 
    67     public TimeSpan TimeLimit {
    68       get { return timeLimit; }
    69       set { timeLimit = value; }
    70     }
    71 
    72     public string ItemName {
    73       get { return ItemAttribute.GetName(this.GetType()); }
    74     }
    75 
    76     public string ItemDescription {
    77       get { return ItemAttribute.GetDescription(this.GetType()); }
    78     }
    79 
    80     public Version ItemVersion {
    81       get { return ItemAttribute.GetVersion(this.GetType()); }
    82     }
    83 
    84     public Image ItemImage {
    85       get { return HeuristicLab.Common.Resources.VSImageLibrary.Event; }
    86     }
    8781
    8882    #endregion
Note: See TracChangeset for help on using the changeset viewer.