From ce07854a45a82e6627da26e2603eb32836182af3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 30 Jan 2008 17:19:32 +0000 Subject: [PATCH] * Insert 'assets served per hour' speed to asset server stats --- .../Statistics/AssetStatsReporter.cs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/OpenSim/Framework/Statistics/AssetStatsReporter.cs b/OpenSim/Framework/Statistics/AssetStatsReporter.cs index ea5add5452..4489c65688 100644 --- a/OpenSim/Framework/Statistics/AssetStatsReporter.cs +++ b/OpenSim/Framework/Statistics/AssetStatsReporter.cs @@ -26,6 +26,7 @@ * */ +using System; using System.Text; using System.Timers; @@ -37,11 +38,12 @@ namespace OpenSim.Grid.AssetServer public class AssetStatsReporter { private Timer ageStatsTimer = new Timer(24 * 60 * 60 * 1000); + private DateTime startTime = DateTime.Now; - private long assetRequestsToday; - public long AssetRequestsToday { get { return assetRequestsToday; } } - + private long assetRequestsToday; private long assetRequestsYesterday; + + public long AssetRequestsToday { get { return assetRequestsToday; } } public long AssetRequestsYesterday { get { return assetRequestsYesterday; } } public AssetStatsReporter() @@ -73,10 +75,17 @@ namespace OpenSim.Grid.AssetServer /// public string Report() { + double elapsedHours = (DateTime.Now - startTime).TotalHours; + if (elapsedHours <= 0) { elapsedHours = 1; } // prevent divide by zero + + long assetRequestsTodayPerHour = (long)Math.Round(AssetRequestsToday / elapsedHours); + long assetRequestsYesterdayPerHour = (long)Math.Round(AssetRequestsYesterday / 24.0); + return string.Format( -@"Asset requests today : {0} -Asset requests yesterday : {1}", - AssetRequestsToday, AssetRequestsYesterday); +@"Asset requests today : {0} ({1} per hour) +Asset requests yesterday : {2} ({3} per hour)", + AssetRequestsToday, assetRequestsTodayPerHour, + AssetRequestsYesterday, assetRequestsYesterdayPerHour); } } }