Example #1
0
        private DynamicJsonValue GetFileMetrics(IoMetrics.FileIoMetrics fileMetric)
        {
            var recent  = new DynamicJsonArray();
            var history = new DynamicJsonArray();
            var djv     = new DynamicJsonValue
            {
                ["File"]    = Path.GetFileName(fileMetric.FileName),
                ["Status"]  = fileMetric.Closed ? "Closed" : "InUse",
                ["Recent"]  = recent,
                ["History"] = history
            };


            foreach (var recentMetric in fileMetric.GetRecentMetrics())
            {
                recent.Add(new DynamicJsonValue
                {
                    ["Start"]      = recentMetric.Start.GetDefaultRavenFormat(),
                    ["Size"]       = recentMetric.Size,
                    ["HumaneSize"] = Sizes.Humane(recentMetric.Size),
                    ["Duration"]   = Math.Round(recentMetric.Duration.TotalMilliseconds, 2),
                    ["Type"]       = recentMetric.Type.ToString()
                });
            }

            foreach (var historyMetric in fileMetric.GetSummaryMetrics())
            {
                history.Add(new DynamicJsonValue
                {
                    ["Start"]          = historyMetric.TotalTimeStart.GetDefaultRavenFormat(),
                    ["End"]            = historyMetric.TotalTimeEnd.GetDefaultRavenFormat(),
                    ["Size"]           = historyMetric.TotalSize,
                    ["HumaneSize"]     = Sizes.Humane(historyMetric.TotalSize),
                    ["Duration"]       = Math.Round((historyMetric.TotalTimeEnd - historyMetric.TotalTimeStart).TotalMilliseconds, 2),
                    ["ActiveDuration"] = Math.Round(historyMetric.TotalTime.TotalMilliseconds, 2),
                    ["MaxDuration"]    = Math.Round(historyMetric.MaxTime.TotalMilliseconds, 2),
                    ["MinDuration"]    = Math.Round(historyMetric.MinTime.TotalMilliseconds, 2),
                    ["Type"]           = historyMetric.Type.ToString()
                });
            }

            return(djv);
        }
Example #2
0
        private static IOMetricsFileStats GetFileMetrics(IoMetrics.FileIoMetrics fileMetric)
        {
            var fileMetrics = new IOMetricsFileStats
            {
                File   = Path.GetFileName(fileMetric.FileName),
                Status = fileMetric.Closed ? FileStatus.Closed : FileStatus.InUse
            };

            foreach (var recentMetric in fileMetric.GetRecentMetrics())
            {
                fileMetrics.Recent.Add(GetIoMetricsRecentStats(recentMetric));
            }

            foreach (var historyMetric in fileMetric.GetSummaryMetrics())
            {
                fileMetrics.History.Add(new IOMetricsHistoryStats
                {
                    Start                = historyMetric.TotalTimeStart.GetDefaultRavenFormat(true),
                    End                  = historyMetric.TotalTimeEnd.GetDefaultRavenFormat(true),
                    Size                 = historyMetric.TotalSize,
                    HumaneSize           = Sizes.Humane(historyMetric.TotalSize),
                    FileSize             = historyMetric.TotalFileSize,
                    HumaneFileSize       = Sizes.Humane(historyMetric.TotalFileSize),
                    Duration             = Math.Round((historyMetric.TotalTimeEnd - historyMetric.TotalTimeStart).TotalMilliseconds, 2),
                    ActiveDuration       = Math.Round(historyMetric.TotalTime.TotalMilliseconds, 2),
                    MaxDuration          = Math.Round(historyMetric.MaxTime.TotalMilliseconds, 2),
                    MinDuration          = Math.Round(historyMetric.MinTime.TotalMilliseconds, 2),
                    MaxAcceleration      = historyMetric.MaxAcceleration,
                    MinAcceleration      = historyMetric.MinAcceleration,
                    CompressedSize       = historyMetric.TotalCompressedSize,
                    HumaneCompressedSize = Sizes.Humane(historyMetric.TotalCompressedSize),
                    Type                 = historyMetric.Type
                });
            }

            return(fileMetrics);
        }