Пример #1
0
        private void RecordElapsed()
        {
            long elapsed = ThreadingHelper.RecordElapsed(_action);

            _accumulator.Accumulate(elapsed);
            if (_verbose)
            {
                Console.WriteLine("{0}: {1}.{2} : {3}ns",
                                  Thread.CurrentThread.Name,
                                  _atomic.GetType().Name,
                                  _action.Method.Name,
                                  elapsed * (1000000.0 / _loop));
            }
        }
Пример #2
0
        void RunTestInParallel()
        {
            _accumulator = new Accumulator();
            Action[] works = new Action[_threadCount];
            for (int i = 0; i < _threadCount; i++)
            {
                works[i] = RecordElapsed;
            }

            ThreadingHelper.RunWorksInParallel(works);
            Console.WriteLine("{0,23}.{1,-18} (ns):{2,6} Average,{3,6} Minimal,{4,6} Maxmial,{5,3} Threads",
                              _atomic.GetType().Name, _action.Method.Name,
                              _accumulator.Average, _accumulator.Minimal,
                              _accumulator.Maximal, _accumulator.Count);
        }