diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs
index 12f646dcc..04e019271 100644
--- a/src/NadekoBot/Modules/Utility/Utility.cs
+++ b/src/NadekoBot/Modules/Utility/Utility.cs
@@ -253,7 +253,7 @@ namespace NadekoBot.Modules.Utility
.AddField(GetText(strs.commands_ran), _stats.CommandsRan.ToString(), true)
.AddField(GetText(strs.messages), $"{_stats.MessageCounter} ({_stats.MessagesPerSecond:F2}/sec)",
true)
- .AddField(GetText(strs.memory), $"{_stats.Heap} MB", true)
+ .AddField(GetText(strs.memory), FormattableString.Invariant($"{_stats.PrivateMemory:F2} MB"), true)
.AddField(GetText(strs.owner_ids), ownerIds, true)
.AddField(GetText(strs.uptime), _stats.GetUptimeString("\n"), true)
.AddField(GetText(strs.presence),
diff --git a/src/NadekoBot/Services/IStatsService.cs b/src/NadekoBot/Services/IStatsService.cs
index f068c88fb..efc409f18 100644
--- a/src/NadekoBot/Services/IStatsService.cs
+++ b/src/NadekoBot/Services/IStatsService.cs
@@ -4,16 +4,55 @@ namespace NadekoBot.Services
{
public interface IStatsService
{
+ ///
+ /// The author of the bot.
+ ///
string Author { get; }
+
+ ///
+ /// The total amount of commands ran since startup.
+ ///
long CommandsRan { get; }
- string Heap { get; }
+
+ ///
+ /// The total amount of private memory used by the bot, in Megabytes.
+ ///
+ double PrivateMemory { get; }
+
+ ///
+ /// The Discord framework used by the bot.
+ ///
string Library { get; }
+
+ ///
+ /// The amount of messages seen by the bot since startup.
+ ///
long MessageCounter { get; }
+
+ ///
+ /// The rate of messages the bot sees every second.
+ ///
double MessagesPerSecond { get; }
+
+ ///
+ /// The total amount of text channels the bot can see.
+ ///
long TextChannels { get; }
+
+ ///
+ /// The total amount of voice channels the bot can see.
+ ///
long VoiceChannels { get; }
+ ///
+ /// Gets for how long the bot has been up since startup.
+ ///
TimeSpan GetUptime();
+
+ ///
+ /// Gets a formatted string of how long the bot has been up since startup.
+ ///
+ /// The formatting separator.
string GetUptimeString(string separator = ", ");
}
}
diff --git a/src/NadekoBot/Services/Impl/StatsService.cs b/src/NadekoBot/Services/Impl/StatsService.cs
index bd6089212..d19d23ea2 100644
--- a/src/NadekoBot/Services/Impl/StatsService.cs
+++ b/src/NadekoBot/Services/Impl/StatsService.cs
@@ -1,20 +1,21 @@
using Discord;
using Discord.WebSocket;
+using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Extensions;
+using Serilog;
using System;
using System.Collections.Generic;
-using System.Globalization;
+using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
-using NadekoBot.Common.ModuleBehaviors;
-using Serilog;
namespace NadekoBot.Services
{
public class StatsService : IStatsService, IReadyExecutor, INService
{
+ private readonly Process _currentProcess = Process.GetCurrentProcess();
private readonly DiscordSocketClient _client;
private readonly IBotCredentials _creds;
private readonly DateTime _started;
@@ -23,8 +24,7 @@ namespace NadekoBot.Services
public string Author => "Kwoth#2452";
public string Library => "Discord.Net";
- public string Heap => Math.Round((double)GC.GetTotalMemory(false) / 1.MiB(), 2)
- .ToString(CultureInfo.InvariantCulture);
+ public double PrivateMemory => _currentProcess.PrivateMemorySize64 / (double)1.MiB();
public double MessagesPerSecond => MessageCounter / GetUptime().TotalSeconds;
private long _textChannels;