Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/18/11 15:08:14 (13 years ago)
Author:
ascheibe
Message:

on behalf of spimming:
#1659

  • implemented abstract base class for benchmarking algorithms
  • added License information
  • corrected plugin dependencies
  • corrected descriptions
Location:
branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3
Files:
1 added
5 edited

Legend:

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

    r6920 r6934  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Diagnostics;
    3 using System.Threading;
    4 using System.Threading.Tasks;
    524using HeuristicLab.Common;
    625using HeuristicLab.Core;
     
    1029
    1130namespace HeuristicLab.Algorithms.Benchmarks {
    12   [Item("Dhrystone Algorithm", "A Dhrystone benchmark algorithm.")]
     31  [Item("Dhrystone Algorithm", "Dhrystone benchmarking algorithm.")]
    1332  [Creatable("Benchmarks")]
    1433  [StorableClass]
    15   public class Dhrystone : Algorithm {
    16     private DateTime lastUpdateTime;
    17 
    18     [Storable]
    19     private ResultCollection results;
     34  public class Dhrystone : Benchmark {
    2035
    2136    #region Benchmark Fields
     
    4661    #endregion
    4762
    48     #region Properties
    49 
    50     public override ResultCollection Results {
    51       get { return results; }
    52     }
    53 
    54     #endregion
    55 
    5663    #region Costructors
    5764
    5865    public Dhrystone()
    5966      : base() {
    60       results = new ResultCollection();
     67
    6168    }
    6269
    6370    private Dhrystone(Dhrystone original, Cloner cloner)
    6471      : base(original, cloner) {
    65       results = new ResultCollection();
    66     }
    67 
    68     #endregion
     72
     73    }
     74
     75    #endregion
     76
     77    #region IDeepClonable Members
    6978
    7079    public override IDeepCloneable Clone(Cloner cloner) {
     
    7281    }
    7382
    74     public override void Prepare() {
    75       results.Clear();
    76       OnPrepared();
    77     }
    78 
    79     public override void Start() {
    80       var cancellationTokenSource = new CancellationTokenSource();
    81       OnStarted();
    82       Task task = Task.Factory.StartNew(Run, cancellationTokenSource.Token, cancellationTokenSource.Token);
    83       task.ContinueWith(t => {
    84         try {
    85           t.Wait();
    86         }
    87         catch (AggregateException ex) {
    88           try {
    89             ex.Flatten().Handle(x => x is OperationCanceledException);
    90           }
    91           catch (AggregateException remaining) {
    92             if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]);
    93             else OnExceptionOccurred(remaining);
    94           }
    95         }
    96         cancellationTokenSource.Dispose();
    97         cancellationTokenSource = null;
    98         OnStopped();
    99       });
    100     }
    101 
    102     private void Run(object state) {
    103       CancellationToken cancellationToken = (CancellationToken)state;
    104       lastUpdateTime = DateTime.Now;
    105       System.Timers.Timer timer = new System.Timers.Timer(250);
    106       timer.AutoReset = true;
    107       timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
    108       timer.Start();
    109       try {
    110         RunBenchmark();
    111       }
    112       finally {
    113         timer.Elapsed -= new System.Timers.ElapsedEventHandler(timer_Elapsed);
    114         timer.Stop();
    115         ExecutionTime += DateTime.Now - lastUpdateTime;
    116       }
    117 
    118       cancellationToken.ThrowIfCancellationRequested();
    119     }
    120 
    121     private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
    122       System.Timers.Timer timer = (System.Timers.Timer)sender;
    123       timer.Enabled = false;
    124       DateTime now = DateTime.Now;
    125       ExecutionTime += now - lastUpdateTime;
    126       lastUpdateTime = now;
    127       timer.Enabled = true;
    128     }
    129 
    130     #region Dhrystone Benchmark
    131 
    132     private void RunBenchmark() {
     83    #endregion
     84
     85    #region Benchmark Methods
     86
     87    protected override void RunBenchmark() {
    13388      int Int_Loc_1;
    13489      int Int_Loc_2;
     
    162117      }
    163118
    164       //System.Console.WriteLine("Execution start, " + Number_Of_Runs + " runs through Dhrystone");
    165119      Stopwatch sw = new Stopwatch();
    166120      sw.Start();
     
    205159      sw.Stop();
    206160      total_time = sw.ElapsedMilliseconds;
    207       //System.Console.WriteLine("total time: {0} ms", total_time);
    208       //System.Console.WriteLine("Result: " + Number_Of_Runs * 1000 / total_time + " dhrystone/ms.");
    209161
    210162      Results.Add(new Result("DIPS", new DoubleValue(Number_Of_Runs * 1000 / total_time)));
     
    389341      public int Int_Comp;
    390342      public string String_Comp;
    391       /*
    392       public int Enum_Comp_2;
    393       public string String_Comp_2;
    394       public char Char_Comp_1;
    395       public char Char_Comp_2;
    396        */
    397343    }
    398344
  • branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/HeuristicLab.Algorithms.Benchmarks-3.3.csproj

    r6920 r6934  
    4040    <Reference Include="System" />
    4141    <Reference Include="System.Core" />
     42    <Reference Include="System.Drawing" />
    4243    <Reference Include="System.Xml.Linq" />
    4344    <Reference Include="System.Data.DataSetExtensions" />
     
    4748  </ItemGroup>
    4849  <ItemGroup>
     50    <Compile Include="Benchmark.cs">
     51      <SubType>Code</SubType>
     52    </Compile>
    4953    <Compile Include="Whetstone.cs" />
    5054    <Compile Include="Dhrystone.cs" />
  • branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/Linpack.cs

    r6920 r6934  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Diagnostics;
    3 using System.Threading;
    4 using System.Threading.Tasks;
    524using HeuristicLab.Common;
    625using HeuristicLab.Core;
     
    1029
    1130namespace HeuristicLab.Algorithms.Benchmarks {
    12   [Item("Linpack Algorithm", "A Linpack benchmark algorithm.")]
     31  [Item("Linpack Algorithm", "Linpack benchmarking algorithm.")]
    1332  [Creatable("Benchmarks")]
    1433  [StorableClass]
    15   public class Linpack : Algorithm {
    16     private DateTime lastUpdateTime;
    17 
    18     [Storable]
    19     private ResultCollection results;
     34  public class Linpack : Benchmark {
    2035
    2136    #region Benchmark Fields
     
    3348    #endregion
    3449
    35     #region Properties
    36 
    37     public override ResultCollection Results {
    38       get { return results; }
    39     }
    40 
    41     #endregion
    42 
    4350    #region Costructors
    4451
    4552    public Linpack()
    4653      : base() {
    47       results = new ResultCollection();
    4854    }
    4955
    5056    private Linpack(Linpack original, Cloner cloner)
    5157      : base(original, cloner) {
    52       results = new ResultCollection();
    5358    }
    5459
    5560    #endregion
     61
     62    #region IDeepClonable Members
    5663
    5764    public override IDeepCloneable Clone(Cloner cloner) {
     
    5966    }
    6067
    61     public override void Prepare() {
    62       results.Clear();
    63       OnPrepared();
    64     }
    65 
    66     public override void Start() {
    67       var cancellationTokenSource = new CancellationTokenSource();
    68       OnStarted();
    69       Task task = Task.Factory.StartNew(Run, cancellationTokenSource.Token, cancellationTokenSource.Token);
    70       task.ContinueWith(t => {
    71         try {
    72           t.Wait();
    73         }
    74         catch (AggregateException ex) {
    75           try {
    76             ex.Flatten().Handle(x => x is OperationCanceledException);
    77           }
    78           catch (AggregateException remaining) {
    79             if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]);
    80             else OnExceptionOccurred(remaining);
    81           }
    82         }
    83         cancellationTokenSource.Dispose();
    84         cancellationTokenSource = null;
    85         OnStopped();
    86       });
    87     }
    88 
    89     private void Run(object state) {
    90       CancellationToken cancellationToken = (CancellationToken)state;
    91       lastUpdateTime = DateTime.Now;
    92       System.Timers.Timer timer = new System.Timers.Timer(250);
    93       timer.AutoReset = true;
    94       timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
    95       timer.Start();
    96       try {
    97         RunBenchmark();
    98       }
    99       finally {
    100         timer.Elapsed -= new System.Timers.ElapsedEventHandler(timer_Elapsed);
    101         timer.Stop();
    102         ExecutionTime += DateTime.Now - lastUpdateTime;
    103       }
    104 
    105       cancellationToken.ThrowIfCancellationRequested();
    106     }
    107 
    108     private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
    109       System.Timers.Timer timer = (System.Timers.Timer)sender;
    110       timer.Enabled = false;
    111       DateTime now = DateTime.Now;
    112       ExecutionTime += now - lastUpdateTime;
    113       lastUpdateTime = now;
    114       timer.Enabled = true;
    115     }
     68    #endregion
    11669
    11770    #region Linpack Benchmark
    118 
    119     private void RunBenchmark() {
     71    // implementation based on Java version: http://www.netlib.org/benchmark/linpackjava/
     72
     73    protected override void RunBenchmark() {
    12074      int n = DEFAULT_PSIZE;
    12175      int ldaa = DEFAULT_PSIZE;
     
    189143      mflops_result /= 1000;
    190144
    191       //System.Console.WriteLine("Mflops/s: " + mflops_result + "  Time: " + time_result + " secs" + "  Norm Res: " + residn_result + "  Precision: " + eps_result);
    192 
    193145      Results.Add(new Result("Mflops/s", new DoubleValue(mflops_result)));
    194       //Results.Add(new Result("ca. Mflops/s", new DoubleValue(mflops_result * Environment.ProcessorCount)));
     146      Results.Add(new Result("total Mflops/s", new DoubleValue(mflops_result * Environment.ProcessorCount)));
    195147    }
    196148
  • branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/Plugin.cs.frame

    r6920 r6934  
    2626  /// Plugin class for HeuristicLab.Algorithms.Benchmark plugin.
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Algorithms.Benchmarks", "Provides wrappers for data analysis algorithms implemented in external libraries (linear regression, linear discriminant analysis, k-means clustering, support vector classification and regression)", "3.4.1.$WCREV$")]
     28  [Plugin("HeuristicLab.Algorithms.Benchmarks", "Provides different benchmarking algorithms", "3.3.5.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Algorithms.Benchmarks-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks/3.3/Whetstone.cs

    r6920 r6934  
    1 using System;
    2 using System.Threading;
    3 using System.Threading.Tasks;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    423using HeuristicLab.Common;
    524using HeuristicLab.Core;
     
    928
    1029namespace HeuristicLab.Algorithms.Benchmarks {
    11   [Item("Whetstone Algorithm", "A Whetstone benchmark algorithm.")]
     30  [Item("Whetstone Algorithm", "Whetstone benchmarking algorithm.")]
    1231  [Creatable("Benchmarks")]
    1332  [StorableClass]
    14   public class Whetstone : Algorithm {
    15     private DateTime lastUpdateTime;
    16 
    17     [Storable]
    18     private ResultCollection results;
     33  public class Whetstone : Benchmark {
    1934
    2035    #region Benchmark Fields
     
    2237    private long begin_time;
    2338    private long end_time;
    24     //private long total_time;
    2539
    2640    private int ITERATIONS;
     
    3448    #endregion
    3549
    36     #region Properties
    37 
    38     public override ResultCollection Results {
    39       get { return results; }
    40     }
    41 
    42     #endregion
    43 
    4450    #region Costructors
    4551
    4652    public Whetstone()
    4753      : base() {
    48       results = new ResultCollection();
     54
    4955    }
    5056
    5157    private Whetstone(Whetstone original, Cloner cloner)
    5258      : base(original, cloner) {
    53       results = new ResultCollection();
    54     }
    55 
    56     #endregion
     59
     60    }
     61
     62    #endregion
     63
     64    #region IDeepClonable Members
    5765
    5866    public override IDeepCloneable Clone(Cloner cloner) {
     
    6068    }
    6169
    62     public override void Prepare() {
    63       results.Clear();
    64       OnPrepared();
    65     }
    66 
    67     public override void Start() {
    68       var cancellationTokenSource = new CancellationTokenSource();
    69       OnStarted();
    70       Task task = Task.Factory.StartNew(Run, cancellationTokenSource.Token, cancellationTokenSource.Token);
    71       task.ContinueWith(t => {
    72         try {
    73           t.Wait();
    74         }
    75         catch (AggregateException ex) {
    76           try {
    77             ex.Flatten().Handle(x => x is OperationCanceledException);
    78           }
    79           catch (AggregateException remaining) {
    80             if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]);
    81             else OnExceptionOccurred(remaining);
    82           }
    83         }
    84         cancellationTokenSource.Dispose();
    85         cancellationTokenSource = null;
    86         OnStopped();
    87       });
    88     }
    89 
    90     private void Run(object state) {
    91       CancellationToken cancellationToken = (CancellationToken)state;
    92       lastUpdateTime = DateTime.Now;
    93       System.Timers.Timer timer = new System.Timers.Timer(250);
    94       timer.AutoReset = true;
    95       timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
    96       timer.Start();
    97       try {
    98         RunBenchmark();
    99       }
    100       finally {
    101         timer.Elapsed -= new System.Timers.ElapsedEventHandler(timer_Elapsed);
    102         timer.Stop();
    103         ExecutionTime += DateTime.Now - lastUpdateTime;
    104       }
    105 
    106       cancellationToken.ThrowIfCancellationRequested();
    107     }
    108 
    109     private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
    110       System.Timers.Timer timer = (System.Timers.Timer)sender;
    111       timer.Enabled = false;
    112       DateTime now = DateTime.Now;
    113       ExecutionTime += now - lastUpdateTime;
    114       lastUpdateTime = now;
    115       timer.Enabled = true;
    116     }
     70    #endregion
    11771
    11872    #region Whetstone Benchmark
    11973
    120     private void RunBenchmark() {
     74    protected override void RunBenchmark() {
    12175      ITERATIONS = 100; // ITERATIONS / 10 = Millions Whetstone instructions
    12276
     
    13084
    13185      for (int runNumber = 1; runNumber <= numberOfRuns; runNumber++) {
    132         //System.Console.WriteLine(runNumber + ". Test");
    13386        elapsedTime = (float)(MainCalc() / 1000);
    13487        meanTime = meanTime + (elapsedTime * 1000 / numberOfCycles);
     
    14295      meanRating = meanRating / numberOfRuns;
    14396      intRating = (int)meanRating;
    144       //System.Console.WriteLine("Number of Runs " + numberOfRuns);
    145       //System.Console.WriteLine("Average time per cycle " + meanTime + " ms.");
    146       //System.Console.WriteLine("Average Whetstone Rating " + intRating + " KWIPS");
    147       //Results.Add(new Result("KWIPS", new IntValue(intRating)));
     97
    14898      Results.Add(new Result("MWIPS", new IntValue(intRating / 1000)));
    14999    }
     
    264214
    265215      end_time = DateTime.Now.Ticks / 10000; // get ms
    266       //System.Console.WriteLine(" (time for " + numberOfCycles + " cycles): " + (end_time - begin_time) + " millisec.");
    267216
    268217      return (end_time - begin_time);
Note: See TracChangeset for help on using the changeset viewer.