BuildingCoder.JtTimer.TimeRegistry.WriteResults C# (CSharp) Метод

WriteResults() публичный статический Метод

Write the report of the results to a text file.
public static WriteResults ( string description, double totalTime ) : void
description string
totalTime double
Результат void
            public static void WriteResults(
                string description,
                double totalTime)
            {
                // Set up text file path:

                string strReportPath = Path.Combine( Path.GetTempPath(), "PerformanceReport.txt" );
                FileStream fs = new FileStream( strReportPath, FileMode.OpenOrCreate, FileAccess.Write );
                StreamWriter streamWriter = new StreamWriter( fs );
                streamWriter.BaseStream.Seek( 0, SeekOrigin.End );

                // Sort output by percentage of total time used:

                List<string> lines = new List<string>( _collection.Count );
                foreach( KeyValuePair<string, Entry> pair in _collection )
                {
                  Entry e = pair.Value;
                  lines.Add( string.Format( "{0,10:0.00}%{1,10:0.00}{2,8}   {3}",
                GetPercent( e.Time, totalTime ),
                Math.Round( e.Time, 2 ),
                e.Calls,
                pair.Key ) );
                }
                lines.Sort();

                string header = " Percentage   Seconds   Calls   Process";
                int n = Math.Max( header.Length, lines.Max<string>( x => x.Length ) );
                if( null != description && 0 < description.Length )
                {
                  n = Math.Max( n, description.Length );
                  header = description + "\r\n" + header;
                }
                string separator = "-";
                while( 0 < n-- )
                {
                  separator += "-";
                }
                streamWriter.WriteLine( separator );
                streamWriter.WriteLine( header );
                streamWriter.WriteLine( separator );

                foreach( string line in lines )
                {
                  streamWriter.WriteLine( line );
                }
                streamWriter.WriteLine( separator + "\r\n" );
                streamWriter.Close();
                fs.Close();
                Process.Start( strReportPath );
                _collection.Clear();
            }