Beispiel #1
0
            /// <summary>
            ///   Initializes a new instance.
            /// </summary>
            public Worker(int index, InvariantChecker context, StateStack stateStack, Func <RuntimeModel> createModel, int successorCapacity)
            {
                _index = index;

                _context     = context;
                _createModel = createModel;
                _model       = _createModel();
                _stateStack  = stateStack;

                var invariant = CompilationVisitor.Compile(_model.Formulas[0]);

                _transitions = new TransitionSet(_model, successorCapacity, invariant);
            }
Beispiel #2
0
        /// <summary>
        ///   Checks the invariant encoded into the model created by <paramref name="createModel" />.
        /// </summary>
        internal AnalysisResult CheckInvariant(Func <RuntimeModel> createModel)
        {
            Requires.That(IntPtr.Size == 8, "Model checking is only supported in 64bit processes.");

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            using (var checker = new InvariantChecker(createModel, message => OutputWritten?.Invoke(message), Configuration))
            {
                var result             = default(AnalysisResult);
                var initializationTime = stopwatch.Elapsed;
                stopwatch.Restart();

                try
                {
                    result = checker.Check();
                    return(result);
                }
                finally
                {
                    stopwatch.Stop();

                    if (!Configuration.ProgressReportsOnly)
                    {
                        OutputWritten?.Invoke(String.Empty);
                        OutputWritten?.Invoke("===============================================");
                        OutputWritten?.Invoke($"Initialization time: {initializationTime}");
                        OutputWritten?.Invoke($"Model checking time: {stopwatch.Elapsed}");
                        OutputWritten?.Invoke($"{(int)(result.StateCount / stopwatch.Elapsed.TotalSeconds):n0} states per second");
                        OutputWritten?.Invoke($"{(int)(result.TransitionCount / stopwatch.Elapsed.TotalSeconds):n0} transitions per second");
                        OutputWritten?.Invoke("===============================================");
                        OutputWritten?.Invoke(String.Empty);
                    }
                }
            }
        }