コード例 #1
0
ファイル: Combination.cs プロジェクト: AnnickS/Items-is-Items
 public void Execute(Item item1, Item item2)
 {
     if (effect != null)
     {
         effect.Execute(item1, item2);
     }
     if (CombinationEvent != null)
     {
         CombinationEvent.Invoke();
     }
 }
コード例 #2
0
        /// <summary>
        /// Run and record the execution times required for the assigned events
        /// </summary>
        /// <param name="label">The label to be reported for this benchmark</param>
        /// <param name="evt">The event object that is to be raised</param>
        private void BenchmarkCombinationEvent(string label, CombinationEvent evt)
        {
            //Create a stopwatch to record the time
            Stopwatch stopwatch = new Stopwatch();

            //Create a collection of times for the two events
            Pair <TimeSpan>[] results = new Pair <TimeSpan> [testRunCount];

            //Run the unity event first
            for (int i = 0; i < testRunCount; i++)
            {
                //Start counting
                stopwatch.Reset();
                stopwatch.Start();

                //Raise the event(s)
                evt.unityEvent.Invoke();

                //Record the time taken
                stopwatch.Stop();
                results[i].first = stopwatch.Elapsed;
            }

            //Run the runtime events
            for (int i = 0; i < testRunCount; i++)
            {
                //Start counting
                stopwatch.Reset();
                stopwatch.Start();

                //Raise the event(s)
                evt.runtimeEvent.Invoke();

                //Record the time taken
                stopwatch.Stop();
                results[i].second = stopwatch.Elapsed;
            }

            //Output the results of the test
            ExportResultsCSV(label, results);
        }