Exemplo n.º 1
0
        public IEnumerable <Part> Write()
        {
            var processors = Utils.GetProcessorCount();

            var partsCount  = (int)(m_fileSize * 2 / Utils.GetAvailableMemory()) + 1;
            var totalBlocks = GetWriteBlocks(partsCount * processors);

            while (totalBlocks.Any())
            {
                yield return(new Part(this, totalBlocks.Take(processors)));

                totalBlocks = totalBlocks.Skip(processors);
            }
        }
Exemplo n.º 2
0
        public int Run(string[] args)
        {
            try
            {
                Console.WriteLine($"{Name}.");
                var stopWatch = new Stopwatch();
                stopWatch.Start();

                if (ParsePrameters(args))
                {
                    var totalFreeRam = Utils.GetAvailableMemory();
                    var processors   = Utils.GetProcessorCount();
                    Console.WriteLine("====================System parameters====================");
                    Console.WriteLine("Available RAM: {0}", Utils.BytesToString(totalFreeRam));
                    Console.WriteLine("Processors: {0}", processors);
                    Console.WriteLine("Available disk space: {0}", Utils.BytesToString(Utils.GetFreeDiskSpace(fileName)));
                    Console.WriteLine("=========================================================");
                    Console.WriteLine("Execution started. To interrupt process press 'Ctrl+C'.");

                    OnExecute();

                    var ts = stopWatch.Elapsed;
                    Console.WriteLine(String.Format("Execution time: {0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10));
                    Console.WriteLine("Press any key...");
                    Console.ReadLine();
                }
                else
                {
                    PrintHelpText();
                }
                return(0);
            }
            catch (Exception ex)
            {
                Error("Unexpected error.", ex);
                return(1);
            }
        }