Beispiel #1
0
        static void WriteStatistics(TextWriter writer, Statistics statistics, ElementSizeStrategy elementSize)
        {
            var actionsNatural = statistics.States * (statistics.TerminalColumns + statistics.NonTerminalColumns);

            writer.WriteLine("		// [Statistics]");
            writer.Write("		// Reductions          : ");
            writer.WriteLine(statistics.Reductions);
            writer.Write("		// Terminals           : ");
            writer.Write(statistics.Terminals);
            writer.Write(" (");
            writer.Write(statistics.TerminalColumns);
            writer.WriteLine(statistics.TerminalColumns == 1 ? " column)" : " columns)");
            writer.Write("		// NonTerminals        : ");
            writer.Write(statistics.NonTerminals);
            writer.Write(" (");
            writer.Write(statistics.NonTerminalColumns);
            writer.WriteLine(statistics.NonTerminalColumns == 1 ? " column)" : " columns)");
            writer.Write("		// States              : ");
            writer.WriteLine(statistics.States);
            writer.Write("		//   Short Circuited   : ");
            writer.WriteLine(statistics.StatesShortCircuited);
            writer.Write("		//   With Goto Entries : ");
            writer.WriteLine(statistics.StatesWithGotos);
            writer.Write("		//   With SR Conflicts : ");
            writer.WriteLine(statistics.StatesWithSRConflicts);
            writer.Write("		//   Other             : ");
            writer.WriteLine(statistics.StatesOther);
            writer.Write("		// Transition Table    : ");
            writer.Write(statistics.ActionsRunTime);
            writer.Write("/");
            writer.Write(actionsNatural);
            writer.Write("(");
            writer.Write(((statistics.ActionsRunTime / (decimal)actionsNatural) * 100).ToString("0.00", CultureInfo.InvariantCulture));
            writer.WriteLine("%)");
            writer.Write("		//   Primary Offsets   : ");
            writer.WriteLine(statistics.States);
            writer.Write("		//   Goto Offsets      : ");
            writer.WriteLine(statistics.GotoOffsetsLen);
            writer.Write("		//   Actions           : ");
            writer.WriteLine(statistics.ActionsRunTime - statistics.States - statistics.GotoOffsetsLen);

            var actionsBytes  = elementSize.Size(statistics.ActionsRunTime);
            var assemblyBytes = statistics.ActionsAssemblyBytes;

            writer.Write("		// Memory Footprint    : ");
            writer.Write(actionsBytes);
            writer.WriteLine(" bytes");
            writer.Write("		// Assembly Footprint  : ");
            writer.Write(assemblyBytes);
            writer.Write(" bytes (");
            writer.Write(((assemblyBytes / (decimal)actionsBytes) * 100).ToString("0.00", CultureInfo.InvariantCulture));
            writer.WriteLine("%)");
        }
Beispiel #2
0
        static void WriteStatistics(TextWriter writer, Statistics statistics, string suffix, ElementSizeStrategy elementSize)
        {
            var transitionsNatural = statistics.States * statistics.CharClassifications;

            writer.Write("		// [Statistics");

            if (!string.IsNullOrEmpty(suffix))
            {
                writer.Write(" Table ");
                writer.Write(suffix);
            }

            writer.WriteLine("]");

            writer.Write("		// Char Classifications : ");
            writer.WriteLine(statistics.CharClassifications);
            writer.Write("		// Char Ranges          : ");
            writer.WriteLine(statistics.CharRanges);
            writer.Write("		// States               : ");
            writer.WriteLine(statistics.States);
            writer.Write("		//   Terminal           : ");
            writer.WriteLine(statistics.StatesTerminal);
            writer.Write("		// Transition Table     : ");
            writer.Write(statistics.TransitionsRunTime);
            writer.Write("/");
            writer.Write(transitionsNatural);
            writer.Write(" (");
            writer.Write(((statistics.TransitionsRunTime / (decimal)transitionsNatural) * 100).ToString("0.00", CultureInfo.InvariantCulture));
            writer.WriteLine("%)");
            writer.Write("		//   Offsets            : ");
            writer.WriteLine(statistics.States);
            writer.Write("		//   Actions            : ");
            writer.WriteLine(statistics.TransitionsRunTime - statistics.States);

            var boundryBytes        = statistics.CharRanges << 1;
            var classificationBytes = elementSize.Size(statistics.CharRanges);
            var transitionBytes     = elementSize.Size(statistics.TransitionsRunTime);
            var tokenTypeBytes      = elementSize.Size(statistics.States);
            var memoryFootprint     = boundryBytes + classificationBytes + transitionBytes + tokenTypeBytes;
            var assemblyFootprint   = boundryBytes + classificationBytes + statistics.TransitionsAssemblyBytes + tokenTypeBytes;

            writer.Write("		// Memory Footprint     : ");
            writer.Write(memoryFootprint);
            writer.WriteLine(" bytes");
            writer.Write("		//   Boundries          : ");
            writer.Write(boundryBytes);
            writer.WriteLine(" bytes");
            writer.Write("		//   Classifications    : ");
            writer.Write(classificationBytes);
            writer.WriteLine(" bytes");
            writer.Write("		//   Transitions        : ");
            writer.Write(transitionBytes);
            writer.WriteLine(" bytes");
            writer.Write("		//   Token Types        : ");
            writer.Write(tokenTypeBytes);
            writer.WriteLine(" bytes");
            writer.Write("		// Assembly Footprint   : ");
            writer.Write(assemblyFootprint);
            writer.Write(" bytes (");
            writer.Write(((assemblyFootprint / (decimal)memoryFootprint) * 100).ToString("0.00", CultureInfo.InvariantCulture));
            writer.WriteLine("%)");
        }