- Timestamp:
- 12/30/11 02:38:12 (12 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.Benchmarks/3.3/Whetstone.cs
r7246 r7247 22 22 using System; 23 23 using System.Diagnostics; 24 using System.Drawing;25 24 using System.Threading; 26 25 using HeuristicLab.Common; … … 31 30 32 31 namespace HeuristicLab.Algorithms.Benchmarks { 33 [Item("Whetstone Benchmark", "Whetstone performance benchmark algorithm.")]32 [Item("Whetstone", "Whetstone performance benchmark.")] 34 33 [StorableClass] 35 public class WhetstoneBenchmark : IBenchmark { 36 [Storable] 37 private byte[][] chunk; 38 public byte[][] ChunkData { 39 get { return chunk; } 40 set { chunk = value; } 41 } 42 43 [Storable] 44 private TimeSpan timeLimit; 45 public TimeSpan TimeLimit { 46 get { return timeLimit; } 47 set { timeLimit = value; } 48 } 49 50 private bool stopBenchmark; 51 52 private CancellationToken cancellationToken; 53 54 public string ItemName { 55 get { return ItemAttribute.GetName(this.GetType()); } 56 } 57 58 public string ItemDescription { 59 get { return ItemAttribute.GetDescription(this.GetType()); } 60 } 61 62 public Version ItemVersion { 63 get { return ItemAttribute.GetVersion(this.GetType()); } 64 } 65 66 public static Image StaticItemImage { 67 get { return HeuristicLab.Common.Resources.VSImageLibrary.Event; } 68 } 69 public Image ItemImage { 70 get { return ItemAttribute.GetImage(this.GetType()); } 71 } 72 73 #region Benchmark Fields 74 34 public sealed class Whetstone : Benchmark { 75 35 private long begin_time; 76 36 private long end_time; … … 84 44 private int i, j, k, l, n1, n2, n3, n4, n6, n7, n8, n9, n10, n11; 85 45 86 #endregion87 88 #region Costructors89 90 46 [StorableConstructor] 91 public WhetstoneBenchmark(bool deserializing) { } 92 93 public WhetstoneBenchmark() { } 94 95 protected WhetstoneBenchmark(WhetstoneBenchmark original, Cloner cloner) { 96 cloner.RegisterClonedObject(original, this); 97 } 98 99 #endregion 100 101 #region Whetstone Benchmark 47 private Whetstone(bool deserializing) : base(deserializing) { } 48 private Whetstone(Whetstone original, Cloner cloner) : base(original, cloner) { } 49 public Whetstone() { } 50 51 public override IDeepCloneable Clone(Cloner cloner) { 52 return new Whetstone(this, cloner); 53 } 54 102 55 // implementation based on Java version: www.aicas.com/download/Whetstone.java 103 104 public void Run(CancellationToken token, ResultCollection results) { 105 cancellationToken = token; 106 stopBenchmark = false; 56 public override void Run(CancellationToken cancellationToken, ResultCollection results) { 57 bool stopBenchmark = false; 107 58 108 59 ITERATIONS = 100; // ITERATIONS / 10 = Millions Whetstone instructions … … 132 83 } 133 84 134 if (( timeLimit == null) || (timeLimit.TotalMilliseconds == 0)) {85 if ((TimeLimit == null) || (TimeLimit.TotalMilliseconds == 0)) { 135 86 if (runNumber > defaultNumberOfRuns) { 136 87 stopBenchmark = true; 137 88 } 138 } else if (sw.Elapsed > timeLimit) {89 } else if (sw.Elapsed > TimeLimit) { 139 90 stopBenchmark = true; 140 91 } … … 293 244 e1[l] = e1[j]; 294 245 } 295 296 #endregion297 298 #region Clone299 300 public IDeepCloneable Clone(Cloner cloner) {301 return new WhetstoneBenchmark(this, cloner);302 }303 304 public object Clone() {305 return Clone(new Cloner());306 }307 308 #endregion309 310 #region Events311 312 public event EventHandler ItemImageChanged;313 protected virtual void OnItemImageChanged() {314 EventHandler handler = ItemImageChanged;315 if (handler != null) handler(this, EventArgs.Empty);316 }317 318 public event EventHandler ToStringChanged;319 protected virtual void OnToStringChanged() {320 EventHandler handler = ToStringChanged;321 if (handler != null) handler(this, EventArgs.Empty);322 }323 324 #endregion325 246 } 326 247 }
Note: See TracChangeset
for help on using the changeset viewer.