Esempio n. 1
0
        public override ResultsReport Execute()
        {
            Status = OperationStatus.Started;
            ValidateAndInitParams();
            GeneratePositionsPlan();
            var results = new ResultsReport(this);

            byte[] data;
            try
            {
                data = InitBuffer();
            }
            catch
            {
                NotEnoughMemUpdate(results, 0);
                return(results);
            }
            var  sw          = new Stopwatch();
            int  prevPercent = -1;
            int  curPercent;
            long currOffset;
            var  i       = 0;
            var  elapsed = new Stopwatch();

            elapsed.Start();
            Status = OperationStatus.Running;
            while (i < _positionsPlan.Length + 1)
            {
                currOffset = _positionsPlan[i];
                i++;
                DoOperation(data, sw, currOffset, i);
                results.AddTroughputMbs(blockSize, currOffset, sw);
                curPercent = Math.Min(100, Math.Max((int)(elapsed.ElapsedMilliseconds / 10 / maxTestTime), (int)(i * 100 / (double)_positionsPlan.Length))
                                      );
                if (curPercent > prevPercent)
                {
                    Update(curPercent, results.GetLatest5AvgResult(), results: results);
                    prevPercent = curPercent;
                    if (curPercent == 100)
                    {
                        break;
                    }
                }
            }
            elapsed.Stop();
            results.TotalTimeMs = elapsed.ElapsedMilliseconds;
            FinalUpdate(results, elapsed.ElapsedMilliseconds);
            return(results);
        }
Esempio n. 2
0
        public override ResultsReport Execute()
        {
            Status = OperationStatus.Started;
            byte[] data;
            int    prevPercent = -1;
            int    curPercent;
            var    results = new ResultsReport(this);
            var    sw      = new Stopwatch();

            try
            {
                data = InitBuffer();
            }
            catch
            {
                NotEnoughMemUpdate(results, 0);
                return(results);
            }
            fileStream.Seek(0, SeekOrigin.Begin);
            RestartElapsed();
            Status = OperationStatus.Running;
            for (var i = 1; i < totalBlocks + 1; i++)
            {
                DoOperation(data, sw);
                if (i == 0)
                {
                    Status = OperationStatus.Running;
                    fileStream.Seek(0, SeekOrigin.Begin);
                }
                if (i > 0)
                {
                    results.AddTroughputMbs(blockSize, fileStream.Position - blockSize, sw);
                    curPercent = (int)(i * 100 / totalBlocks);
                    if (curPercent > prevPercent)
                    {
                        Update(curPercent, results.GetLatest5AvgResult(), results: results);
                        prevPercent = curPercent;
                    }
                }
            }
            results.TotalTimeMs = StopElapsed();
            FinalUpdate(results, ElapsedMs);
            TestCompleted();
            return(results);
        }