Пример #1
0
        // Big Test MSG
        private BigTest GetBTMSG(byte[] msg, Int64 msgSize)
        {
            Int32 type = ByteInt32(msg[8]);

            byte[] seq_num = new byte[4];
            byte[] vars    = new byte[msgSize - 13];

            Array.Copy(msg, 9, seq_num, 0, 4);
            Array.Copy(msg, 13, vars, 0, msgSize - 13);

            BigTest BTMSG = BTMSGVars(vars);

            BTMSG.msgType = type;
            return(BTMSG);
        }
Пример #2
0
        List <BenchmarkPartialResult> DoInternalBenchmark()
        {
            List <BenchmarkPartialResult> result = new List <BenchmarkPartialResult>();

            base.WriteMessage("STORAGE SPEED TEST\n");

            //Console.ForegroundColor = ConsoleColor.DarkGray;
            //base.WriteMessage("Total RAM: {0:0.00}Gb, Available RAM: {1:0.00}Gb\n", (double)RamDiskUtil.TotalRam / 1024 / 1024 / 1024, (double)RamDiskUtil.FreeRam / 1024 / 1024 / 1024);
            WriteLineWordWrap("The test uses standrd OS's file API (WinAPI on Windows and POSIX on Mac/Linux) to measure the speed of transfers between storage device and system memory.\nWrite buffering and mem cahce are disabled\n");
            //Console.ResetColor();

            const long fileSize = 1024 * 1024 * 1024;

            //var drivePath = PickDrive(fileSize);

            //if (drivePath == null) return result;

            var drivers = RamDiskUtil.GetEligibleDrives();

            foreach (var driver in drivers)
            {
                try
                {
                    if (driver.TotalFreeSpace < fileSize)
                    {
                        base.WriteMessage($"CANNOT BENCHMARK LOCAL STORAGE SPEED FOR DRIVER [{driver.Name}] - Not enough space");
                    }
                    else
                    {
                        var testSuite = new BigTest(driver.Name, fileSize, false);
                        result.AddRange(DoDiskBenchmark(testSuite, driver.Name));
                    }
                }
                catch (Exception ex)
                {
                    string message = $"Error while test disk [{driver.Name}]";
                    base.WriteMessage(message + ex.ToString());
                }
            }

            return(result);
        }
Пример #3
0
        private BigTest BTMSGVars(byte[] vars)
        {
            byte[] from = new byte[4];
            byte[] pos  = new byte[12];
            byte[] pR   = new byte[16];
            byte[] cR   = new byte[16];

            int index = 0;

            //Console.WriteLine(vars.Length);
            Array.Copy(vars, index, from, 0, 4);
            index += 4;
            Array.Copy(vars, index, pos, 0, 12);
            index += 12;
            Array.Copy(vars, index, pR, 0, 16);
            index += 16;
            Array.Copy(vars, index, cR, 0, 16);

            BigTest msg = new BigTest();

            return(msg);
        }
Пример #4
0
 public byte[] SerializeMSG(BigTest msg)
 {
     byte[] header = Header(msg.msgType);
     byte[] body   = BuildMSG(msg.userId, msg.positions, msg.rotation);
     return(Combine(IntByte((Int64)8 + header.Length + body.Length), header, body));
 }
Пример #5
0
        private List <BenchmarkPartialResult> DoDiskBenchmark(BigTest testSuite, string driverName)
        {
            List <BenchmarkPartialResult> result = new List <BenchmarkPartialResult>();

            try
            {
                using (testSuite)
                {
                    base.WriteMessage(string.Format("Test file: {0}, Size: {1:0.00}Gb\n\n Press ESC to break", testSuite.FilePath, (double)testSuite.FileSize / 1024 / 1024 / 1024));

                    string    currentTest = null;
                    const int curCursor   = 40;
                    var       breakTest   = false;

                    testSuite.StatusUpdate += (sender, e) =>
                    {
                        if (breakTest)
                        {
                            return;
                        }
                        //if (e.Status == TestStatus.NotStarted) return;

                        if ((sender as Test).DisplayName != currentTest)
                        {
                            currentTest = (sender as Test).DisplayName;
                            TryWriteConsole(string.Format("\n{0}/{1} {2}", testSuite.CompletedTests + 1, testSuite.TotalTests, (sender as Test).DisplayName));
                        }

                        ClearLine(curCursor);

                        if (e.Status != TestStatus.Completed)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkGray;
                            switch (e.Status)
                            {
                            case TestStatus.Started:
                                TryWriteConsole(string.Format("Started"));
                                break;

                            case TestStatus.InitMemBuffer:
                                TryWriteConsole(string.Format("Initializing test data in RAM..."));
                                break;

                            case TestStatus.PurgingMemCache:
                                TryWriteConsole(string.Format("Purging file cache in RAM..."));
                                break;

                            case TestStatus.WarmigUp:
                                TryWriteConsole(string.Format("Warming up..."));
                                break;

                            case TestStatus.Interrupted:
                                TryWriteConsole(string.Format("Test interrupted"));
                                break;

                            case TestStatus.Running:
                                TryWriteConsole(string.Format("{0}% {2} {1:0.00} MB/s", e.ProgressPercent, e.RecentResult, GetNextAnimation()));
                                break;
                            }
                            // Console.ResetColor();
                        }
                        else if ((e.Status == TestStatus.Completed) && (e.Results != null))
                        {
                            TryWriteConsole(string.Format(
                                                string.Format("Avg: {1:0.00}{0}\t",
                                                              unit,
                                                              e.Results.AvgThroughput))
                                            );

                            //Console.ForegroundColor = ConsoleColor.DarkGray;
                            TryWriteConsole(string.Format(
                                                string.Format(" Min÷Max: {1:0.00} ÷ {2:0.00}, Time: {3}m{4:00}s",
                                                              unit,
                                                              e.Results.Min,
                                                              e.Results.Max,
                                                              e.ElapsedMs / 1000 / 60,
                                                              e.ElapsedMs / 1000 % 60))
                                            );
                            //Console.ResetColor();
                        }

                        /*if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)
                         * {
                         *  base.WriteMessage("  Stopping...");
                         *  breakTest = true;
                         *  testSuite.Break();
                         * }*/

                        try
                        {
                            ShowCounters(testSuite);
                        }
                        catch (Exception ex)
                        {
                            //TODO: IMPLEMENTAR EXCEPTION
                            System.Diagnostics.Debugger.Log(0, "", ex.ToString());
                        }
                    };

                    var results = testSuite.Execute();

                    if (!breakTest)
                    {
                        base.WriteMessage(string.Format("\n\nWrite Score*:\t {0:0.00} MB/s", testSuite.WriteScore));
                        base.WriteMessage(string.Format("Read Score*:\t {0:0.00} MB/s", testSuite.ReadScore));
                        Console.ForegroundColor = ConsoleColor.DarkGray;
                        base.WriteMessage("*Calculation: average throughput with 80% read/written seqentialy and 20% randomly");
                        Console.ResetColor();
                        base.WriteMessage("\nTest file deleted.");

                        result.Add(new BenchmarkPartialResult()
                        {
                            Description = $"LOCAL STORAGE SPEED - WRITE [{driverName}]",
                            MetricScale = MetricScaleType.MEGABYTE,
                            ResultType  = BenchmarkResultType.UPLOAD_SPEED,
                            Score       = Math.Round(testSuite.WriteScore, 2)
                        });

                        result.Add(new BenchmarkPartialResult()
                        {
                            Description = $"LOCAL STORAGE SPEED - READ [{driverName}]",
                            MetricScale = MetricScaleType.MEGABYTE,
                            ResultType  = BenchmarkResultType.UPLOAD_SPEED,
                            Score       = Math.Round(testSuite.ReadScore, 2)
                        });


                        //result.Score = Math.Round((testSuite.WriteScore + testSuite.ReadScore) / 2,2);
                        //result.StepsDetails.Add(string.Format("Write Score*:\t {0:0.00} MB/s", testSuite.WriteScore) + " | " + string.Format("Read Score*:\t {0:0.00} MB/s", testSuite.ReadScore));
                        //base.WriteMessage("\nTest file deleted.  Saving results to CSV files in folder: " + testSuite.ResultsFolderPath);
                        //testSuite.ExportToCsv(testSuite.ResultsFolderPath, true);
                    }
                }
            }
            catch (Exception ex)
            {
                base.WriteMessage("\nProgram interupted due to unexpected error:");
                base.WriteMessage("\t" + ex.GetType() + " " + ex.Message);
                base.WriteMessage(ex.StackTrace);
            }

            /*if (!RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX))
             * {
             *  base.WriteMessage("\nPress any key to quit");
             *  Console.ReadKey();
             * }*/

            return(result);
        }
Пример #6
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("CPDT_Console - STORAGE SPEED TEST\n");

                Console.ForegroundColor = ConsoleColor.DarkGray;
                //Console.WriteLine("Total RAM: {0:0.00}Gb, Available RAM: {1:0.00}Gb\n", (double)RamDiskUtil.TotalRam / 1024 / 1024 / 1024, (double)RamDiskUtil.FreeRam / 1024 / 1024 / 1024);
                WriteLineWordWrap("The test uses standrd OS's file API (WinAPI on Windows and POSIX on Mac/Linux) to measure the speed of transfers between storage device and system memory.\nWrite buffering and mem cahce are disabled\n");
                Console.ResetColor();

                const long fileSize = 1024 * 1024 * 1024;

                var drivePath = PickDrive(fileSize);

                if (drivePath == null)
                {
                    return;
                }

                var testSuite = new BigTest(drivePath, fileSize, false);

                using (testSuite)
                {
                    Console.WriteLine("Test file: {0}, Size: {1:0.00}Gb\n\n Press ESC to break", testSuite.FilePath, (double)testSuite.FileSize / 1024 / 1024 / 1024);

                    string    currentTest = null;
                    const int curCursor   = 40;
                    var       breakTest   = false;

                    testSuite.StatusUpdate += (sender, e) =>
                    {
                        if (breakTest)
                        {
                            return;
                        }
                        if (e.Status == TestStatus.NotStarted)
                        {
                            return;
                        }

                        if ((sender as Test).DisplayName != currentTest)
                        {
                            currentTest = (sender as Test).DisplayName;
                            Console.Write("\n{0}/{1} {2}", testSuite.CompletedTests + 1, testSuite.TotalTests, (sender as Test).DisplayName);
                        }

                        ClearLine(curCursor);

                        if (e.Status != TestStatus.Completed)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkGray;
                            switch (e.Status)
                            {
                            case TestStatus.Started:
                                Console.Write("Started");
                                break;

                            case TestStatus.InitMemBuffer:
                                Console.Write("Initializing test data in RAM...");
                                break;

                            case TestStatus.PurgingMemCache:
                                Console.Write("Purging file cache in RAM...");
                                break;

                            case TestStatus.WarmigUp:
                                Console.Write("Warming up...");
                                break;

                            case TestStatus.Interrupted:
                                Console.Write("Test interrupted");
                                break;

                            case TestStatus.Running:
                                Console.Write("{0}% {2} {1:0.00} MB/s", e.ProgressPercent, e.RecentResult, GetNextAnimation());
                                break;
                            }
                            Console.ResetColor();
                        }
                        else if ((e.Status == TestStatus.Completed) && (e.Results != null))
                        {
                            Console.Write(
                                string.Format("Avg: {1:0.00}{0}\t",
                                              unit,
                                              e.Results.AvgThroughput)
                                );

                            Console.ForegroundColor = ConsoleColor.DarkGray;
                            Console.Write(
                                string.Format(" Min÷Max: {1:0.00} ÷ {2:0.00}, Time: {3}m{4:00}s",
                                              unit,
                                              e.Results.Min,
                                              e.Results.Max,
                                              e.ElapsedMs / 1000 / 60,
                                              e.ElapsedMs / 1000 % 60)
                                );
                            Console.ResetColor();
                        }

                        if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)
                        {
                            Console.WriteLine("  Stopping...");
                            breakTest = true;
                            testSuite.Break();
                        }

                        ShowCounters(testSuite);
                    };

                    var results = testSuite.Execute();

                    if (!breakTest)
                    {
                        Console.WriteLine("\n\nWrite Score*:\t {0:0.00} MB/s", testSuite.WriteScore);
                        Console.WriteLine("Read Score*:\t {0:0.00} MB/s", testSuite.ReadScore);
                        Console.ForegroundColor = ConsoleColor.DarkGray;
                        Console.WriteLine("*Calculation: average throughput with 80% read/written seqentialy and 20% randomly");
                        Console.ResetColor();
                        Console.WriteLine("\nTest file deleted.");
                        //Console.WriteLine("\nTest file deleted.  Saving results to CSV files in folder: " + testSuite.ResultsFolderPath);
                        //testSuite.ExportToCsv(testSuite.ResultsFolderPath, true);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("\nProgram interupted due to unexpected error:");
                Console.WriteLine("\t" + ex.GetType() + " " + ex.Message);
                Console.WriteLine(ex.StackTrace);
            }

            if (!RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX))
            {
                Console.WriteLine("\nPress any key to quit");
                Console.ReadKey();
            }
        }