Example #1
0
        public static bool RunTest(DiskSpeedTarget testTarget, DiskSpeedParameter testParameter, out DiskSpeedResult testResult)
        {
            if (testTarget == null)
            {
                throw new ArgumentNullException(nameof(testTarget));
            }
            if (testParameter == null)
            {
                throw new ArgumentNullException(nameof(testParameter));
            }

            testResult = new DiskSpeedResult();
            if (DiskSpeedTool.RunSpeedTest(testTarget, testParameter, out string xml) != 0)
            {
                return(false);
            }

            // Parse results
            testResult.FromXml(xml);

            return(true);
        }
Example #2
0
        public void AddResult(DiskSpeedTarget testTarget, DiskSpeedParameter testParameter, DiskSpeedResult testResult)
        {
            if (testTarget == null)
            {
                throw new ArgumentNullException(nameof(testTarget));
            }
            if (testParameter == null)
            {
                throw new ArgumentNullException(nameof(testParameter));
            }
            if (testResult == null)
            {
                throw new ArgumentNullException(nameof(testResult));
            }

            // Add a result line
            string result = $"{DateTime.UtcNow:s},\"{testTarget.FileName}\",{testTarget.FileSize},{testParameter.BlockSizeString}" +
                            $",{testParameter.WriteRatioString},{testParameter.ThreadCount},{testParameter.OutstandingOperations}" +
                            $",{testParameter.WarmupTime},{testResult.Seconds},{testResult.Bytes},{testResult.Ios}";

            File.AppendAllText(FileName, result + Environment.NewLine);
        }