示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("SSD Stress Tester - https://github.com/m-ober/SSDStressTest");
            Console.WriteLine("USE AT YOUR OWN RISK! THIS TOOL MAY DAMAGE YOUR DRIVE!");
            Console.WriteLine("");

            if (parseParameters(args))
            {
                long free;
                long total;
                disk.QuerySpace(out free, out total);

                StringBuilder header = new StringBuilder();
                header.AppendLine("'Log file name: " + outputFile)
                .AppendLine("'Logging started on " + DateTime.Now)
                .AppendLine("'Product name: " + disk.productName)
                .AppendLine("'Disk PNP ID: " + disk.pnpId)
                .AppendLine("'Blocksize: " + FormatSize(blocksize_b))
                .AppendLine("'Testsize: " + FormatSize(testsize_b))
                .AppendLine("'Free disk space: " + FormatSize(free))
                .AppendLine("'Total disk space: " + FormatSize(total));

                if (howLong > 0)
                {
                    header.AppendLine("'Running test for " + howLong + " minute(s)");
                }
                else
                {
                    header.AppendLine("'Running test until stopped (press ESC).");
                }

                if (smartParams.Count > 0)
                {
                    header.AppendLine("Time,MBytesWritten,Performance,InstPerformance,"
                                      + String.Join(",", smartParams));
                }
                else
                {
                    header.AppendLine("Time,MBytesWritten,Performance,InstPerformance,Temperature");
                }

                string s = header.ToString();
                logfile.Write(s);
                Console.Write(s);
                Console.WriteLine();

                start_time          = DateTime.Now;
                queryTimer          = new System.Timers.Timer(timeOut);
                queryTimer.Elapsed += new ElapsedEventHandler(queryData);
                queryTimer.Enabled  = true;

                worker = new BenchmarkWorker();
                worker.SetDrive(driveLetter);
                worker.SetBlocksize(blocksize_b);
                worker.SetTestSize(testsize_b);
                workerThread = new Thread(worker.DoWork);
                workerThread.Start();
                Console.WriteLine("Starting benchmark...");
                while (!workerThread.IsAlive)
                {
                    ;
                }

                while (true)
                {
                    if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)
                    {
                        break;
                    }

                    if (howLong > 0 && Math.Floor((DateTime.Now - start_time).TotalSeconds) > howLong * 60)
                    {
                        break;
                    }

                    Thread.Sleep(100);
                }

                worker.RequestStop();
                queryTimer.Enabled = false;
                workerThread.Join();
                Console.WriteLine("Test stopped.");

                logfile.Close();

                Console.WriteLine();
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey(true);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("SSD Stress Tester - https://github.com/m-ober/SSDStressTest");
            Console.WriteLine("USE AT YOUR OWN RISK! THIS TOOL MAY DAMAGE YOUR DRIVE!");
            Console.WriteLine("");

            if (parseParameters(args))
            {
                long free;
                long total;
                disk.QuerySpace(out free, out total);

                StringBuilder header = new StringBuilder();
                header.AppendLine("'Log file name: " + outputFile)
                    .AppendLine("'Logging started on " + DateTime.Now)
                    .AppendLine("'Product name: " + disk.productName)
                    .AppendLine("'Disk PNP ID: " + disk.pnpId)
                    .AppendLine("'Blocksize: " + FormatSize(blocksize_b))
                    .AppendLine("'Testsize: " + FormatSize(testsize_b))
                    .AppendLine("'Free disk space: " + FormatSize(free))
                    .AppendLine("'Total disk space: " + FormatSize(total));

                if (howLong > 0)
                    header.AppendLine("'Running test for " + howLong + " minute(s)");
                else
                    header.AppendLine("'Running test until stopped (press ESC).");

                if (smartParams.Count > 0)
                    header.AppendLine("Time,MBytesWritten,Performance,InstPerformance,"
                        + String.Join(",", smartParams));
                else
                    header.AppendLine("Time,MBytesWritten,Performance,InstPerformance,Temperature");

                string s = header.ToString();
                logfile.Write(s);
                Console.Write(s);
                Console.WriteLine();

                start_time = DateTime.Now;
                queryTimer = new System.Timers.Timer(timeOut);
                queryTimer.Elapsed += new ElapsedEventHandler(queryData);
                queryTimer.Enabled = true;

                worker = new BenchmarkWorker();
                worker.SetDrive(driveLetter);
                worker.SetBlocksize(blocksize_b);
                worker.SetTestSize(testsize_b);
                workerThread = new Thread(worker.DoWork);
                workerThread.Start();
                Console.WriteLine("Starting benchmark...");
                while (!workerThread.IsAlive) ;

                while (true)
                {
                    if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)
                        break;

                    if (howLong > 0 && Math.Floor((DateTime.Now - start_time).TotalSeconds) > howLong * 60)
                        break;

                    Thread.Sleep(100);
                }

                worker.RequestStop();
                queryTimer.Enabled = false;
                workerThread.Join();
                Console.WriteLine("Test stopped.");

                logfile.Close();

                Console.WriteLine();
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey(true);
            }
        }