Simulator.DebugLogger.WriteStatus C# (CSharp) Method

WriteStatus() public method

public WriteStatus ( string status ) : void
status string
return void
        public void WriteStatus(string status, params Object[] args)
        {
            DateTime now = DateTime.UtcNow;
            TimeSpan eventTime = now - whenStarted;
            TimeSpan sinceLastEvent = now - _lastEventTime;
            long eventMemory = GC.GetTotalMemory(false);
            long memDiff = eventMemory - _lastMemory;
            long eventMemoryMB = eventMemory / (1024L * 1024L);
            long memDiffMB = memDiff / (1024L * 1024L);
            _lastMemory = eventMemory;
            _lastEventTime = now;
            Console.Out.WriteLine("Time: {0:00}:{1:00}:{2:00}.{3:000} seconds ({4:0.000}),  Memory: {5}MB (increased by {6}MB)",
                eventTime.Hours,
                eventTime.Minutes,
                eventTime.Seconds,
                eventTime.Milliseconds,
                sinceLastEvent.TotalSeconds,
                eventMemoryMB, memDiffMB);
            Console.Out.WriteLine(status, args);
            lock (writer)
            {
                writer.WriteLine(
                    "Time: {0:00}:{1:00}:{2:00}.{3:000} seconds ({4:0.000}),  Memory: {5}MB (increased by {6}MB)",
                    eventTime.Hours,
                    eventTime.Minutes,
                    eventTime.Seconds,
                    eventTime.Milliseconds,
                    sinceLastEvent.TotalSeconds,
                    eventMemoryMB, memDiffMB);
                writer.WriteLine(status, args);
                writer.Flush();
            }
        }
    }

Usage Example

Beispiel #1
0
        //public void ReduceMemoryUsage(object sender, MemoryUsageLimiter.ReduceMemoryUsageEventParameters parameters)
        //{
        //_ipHistoryCache.RecoverSpace(parameters.FractionOfMemoryToTryToRemove);
        //}

        public Simulator(DebugLogger logger, string path, ExperimentalConfiguration myExperimentalConfiguration, SimulatedPasswords simPasswords)
        {
            _simPasswords = simPasswords;
            _logger       = logger;
            _AttackAttemptsWithValidPasswords = //System.IO.TextWriter.Synchronized
                                                new ConcurrentStreamWriter(path + "AttackAttemptsWithValidPasswords.txt");
            //(new StreamWriter(new FileStream(path + "AttackAttemptsWithValidPasswords.txt", FileMode.CreateNew, FileAccess.Write)));
            _LegitimateAttemptsWithValidPasswords = //System.IO.TextWriter.Synchronized
                                                    new ConcurrentStreamWriter(path + "LegitimateAttemptsWithValidPasswords.txt");
            //(new StreamWriter(new FileStream(path + "LegitiamteAttemptsWithValidPasswords.txt", FileMode.CreateNew, FileAccess.Write)));
            _OtherAttempts = //System.IO.TextWriter.Synchronized
                             new ConcurrentStreamWriter(path + "OtherAttempts.txt");
            //(new StreamWriter(new FileStream(path + "OtherAttempts.txt", FileMode.CreateNew, FileAccess.Write)));
            _logger.WriteStatus("Entered Simulator constructor");
            _experimentalConfiguration = myExperimentalConfiguration;
            BlockingAlgorithmOptions options = _experimentalConfiguration.BlockingOptions;

            _logger.WriteStatus("Creating binomial ladder");
            _binomialLadderFilter =
                new BinomialLadderFilter(options.NumberOfBitsInBinomialLadderFilter_N, options.HeightOfBinomialLadder_H);
            _ipHistoryCache        = new ConcurrentDictionary <IPAddress, SimIpHistory>(); // new SelfLoadingCache<IPAddress, SimIpHistory>(address => new SimIpHistory(options.NumberOfFailuresToTrackForGoingBackInTimeToIdentifyTypos));
            _userAccountController = new SimulatedUserAccountController();

            //_memoryUsageLimiter = new MemoryUsageLimiter();
            //_memoryUsageLimiter.OnReduceMemoryUsageEventHandler += ReduceMemoryUsage;

            _recentIncorrectPasswords = new AgingMembershipSketch(16, 128 * 1024);

            _logger.WriteStatus("Exiting Simulator constructor");
        }
All Usage Examples Of Simulator.DebugLogger::WriteStatus