예제 #1
0
        private void DoWork(SmashContext tparam)
        {
            System.Threading.ManualResetEvent startEvent = tparam.StartEvent;
            System.Threading.Interlocked.Increment(ref _taskReadyCount);
            if (!startEvent.WaitOne())
            {
                throw new SmashException(string.Format("Thread #{0} fail to start", tparam.ThreadNo));
            }

            SmashStopwatch swTask = new SmashStopwatch(tparam.NumIterations);

            SmashResult result = new SmashResult();

            result.SuccessfulIterations = 0;
            for (int i = 0; i < tparam.NumIterations; ++i)
            {
                if (tparam.SmashFunc(tparam.ThreadNo, i))
                {
                    result.SuccessfulIterations++;
                }
            }
            swTask.Done();

            SmashAssert.AreEqual(tparam.NumIterations, result.SuccessfulIterations);
            result.TimeTaken  = swTask.Elapsed;
            result.RatePerSec = swTask.RatePerSec;

            tparam.Manager.SubmitResult(tparam.ThreadNo, result);
        }
예제 #2
0
 private void SubmitResult(int tno, SmashResult result)
 {
     _threadResults[tno] = result;
 }