PowerArgs.Cli.CliProfiler.Dump C# (CSharp) Method

Dump() public method

public Dump ( string file ) : void
file string
return void
        public void Dump(string file)
        {
            var ret = "";
            foreach (var prop in GetType().GetProperties())
            {
                ret += prop.Name + " = " + prop.GetValue(this) + Environment.NewLine;
            }

            if (timeSamples.Count > 0)
            {
                ret += "\nTime Samples"+Environment.NewLine+Environment.NewLine;
                foreach (var key in timeSamples.Keys)
                {
                    var avg = timeSamples[key].Average(t => t.TotalMilliseconds);
                    var min = timeSamples[key].Min(t => t.TotalMilliseconds);
                    var max = timeSamples[key].Max(t => t.TotalMilliseconds);
                    ret += $"{key} (AVG: {avg}) (MIN: {min}) (MAX: {max})"+Environment.NewLine+Environment.NewLine;

                    foreach(var sample in timeSamples[key])
                    {
                        ret += "    "+(int)sample.TotalMilliseconds+" ms"+Environment.NewLine;
                    }
                }
            }

            File.WriteAllText(file, ret);
        }