Changeset 6987 for branches/Benchmarking/sources
- Timestamp:
- 11/14/11 14:12:51 (13 years ago)
- 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 276 276 private void CreateParameters() { 277 277 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))); 279 279 } 280 280 … … 292 292 Parameters.Add(new ConstrainedValueParameter<IBenchmark>(paramName, values, values.First(a => a is IBenchmark))); 293 293 } else { 294 // throw exception?295 294 Parameters.Add(new ConstrainedValueParameter<IBenchmark>(paramName, values)); 296 295 } … … 363 362 if (chunkSize > 0) { 364 363 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; 367 372 BenchmarkAlgorithm.Run(cancellationToken, results); 368 373 } 369 374 catch (OperationCanceledException) { 370 //Console.WriteLine(ex.ToString());371 375 } 372 376 finally { … … 411 415 } 412 416 } 413 values.Add("Benchmark Name", new StringValue(Name));414 values.Add("Benchmark Type", new StringValue(this.GetType().GetPrettyName()));415 417 } 416 418 … … 426 428 return chunk; 427 429 } 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 */441 430 442 431 #region Events -
branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/DhrystoneBenchmark.cs
r6948 r6987 36 36 [Storable] 37 37 private byte[][] chunk; 38 public byte[][] ChunkData { 39 get { return chunk; } 40 set { chunk = value; } 41 } 38 42 39 43 private TimeSpan timeLimit; 44 public TimeSpan TimeLimit { 45 get { return timeLimit; } 46 set { timeLimit = value; } 47 } 40 48 41 49 private bool stopBenchmark; 42 50 43 51 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 } 44 68 45 69 #region Benchmark Fields … … 67 91 68 92 private long Default_Number_Of_Runs = 10000000; 69 70 #endregion71 72 #region Properties73 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 }99 93 100 94 #endregion -
branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/LinpackBenchmark.cs
r6948 r6987 36 36 [Storable] 37 37 private byte[][] chunk; 38 public byte[][] ChunkData { 39 get { return chunk; } 40 set { chunk = value; } 41 } 38 42 39 43 private TimeSpan timeLimit; 44 public TimeSpan TimeLimit { 45 get { return timeLimit; } 46 set { timeLimit = value; } 47 } 40 48 41 49 private bool stopBenchmark; 42 50 43 51 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 } 44 68 45 69 #region Benchmark Fields … … 54 78 55 79 private Stopwatch sw = new Stopwatch(); 56 57 #endregion58 59 #region Properties60 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 }86 80 87 81 #endregion … … 197 191 198 192 executionTime += sw.Elapsed; 199 if ( timeLimit == null)193 if ((timeLimit == null) || (timeLimit.TotalMilliseconds == 0)) 200 194 stopBenchmark = true; 201 195 else if (executionTime > timeLimit) -
branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/WhetstoneAlgorithm.cs
r6948 r6987 36 36 [Storable] 37 37 private byte[][] chunk; 38 public byte[][] ChunkData { 39 get { return chunk; } 40 set { chunk = value; } 41 } 38 42 39 43 private TimeSpan timeLimit; 44 public TimeSpan TimeLimit { 45 get { return timeLimit; } 46 set { timeLimit = value; } 47 } 40 48 41 49 private bool stopBenchmark; 42 50 43 51 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 } 44 68 45 69 #region Benchmark Fields … … 55 79 private double[] e1 = new double[4]; 56 80 private int i, j, k, l, n1, n2, n3, n4, n6, n7, n8, n9, n10, n11; 57 58 #endregion59 60 #region Properties61 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 }87 81 88 82 #endregion
Note: See TracChangeset
for help on using the changeset viewer.