Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -21,109 +21,120 @@
using System;
using System.Diagnostics;
namespace Server {
public sealed class SaveMetrics : IDisposable {
private const string PerformanceCategoryName = "RunUO 2.1";
private const string PerformanceCategoryDesc = "Performance counters for RunUO 2.1.";
namespace Server
{
public sealed class SaveMetrics : IDisposable
{
private const string PerformanceCategoryName = "RunUO 2.1";
private const string PerformanceCategoryDesc = "Performance counters for RunUO 2.1.";
private PerformanceCounter numberOfWorldSaves;
private bool isDisposed;
private PerformanceCounter itemsPerSecond;
private PerformanceCounter mobilesPerSecond;
private PerformanceCounter itemsPerSecond;
private PerformanceCounter mobilesPerSecond;
private PerformanceCounter serializedBytesPerSecond;
private PerformanceCounter writtenBytesPerSecond;
private PerformanceCounter numberOfWorldSaves;
public SaveMetrics() {
if ( !PerformanceCounterCategory.Exists( PerformanceCategoryName ) ) {
CounterCreationDataCollection counters = new CounterCreationDataCollection();
private PerformanceCounter serializedBytesPerSecond;
private PerformanceCounter writtenBytesPerSecond;
counters.Add( new CounterCreationData(
"Save - Count",
"Number of world saves.",
PerformanceCounterType.NumberOfItems32
)
);
public SaveMetrics()
{
if (!PerformanceCounterCategory.Exists(PerformanceCategoryName))
{
CounterCreationDataCollection counters = new CounterCreationDataCollection();
counters.Add( new CounterCreationData(
"Save - Items/sec",
"Number of items saved per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
counters.Add(new CounterCreationData(
"Save - Count",
"Number of world saves.",
PerformanceCounterType.NumberOfItems32
)
);
counters.Add( new CounterCreationData(
"Save - Mobiles/sec",
"Number of mobiles saved per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
counters.Add(new CounterCreationData(
"Save - Items/sec",
"Number of items saved per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
counters.Add( new CounterCreationData(
"Save - Serialized bytes/sec",
"Amount of world-save bytes serialized per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
counters.Add(new CounterCreationData(
"Save - Mobiles/sec",
"Number of mobiles saved per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
counters.Add( new CounterCreationData(
"Save - Written bytes/sec",
"Amount of world-save bytes written to disk per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
counters.Add(new CounterCreationData(
"Save - Serialized bytes/sec",
"Amount of world-save bytes serialized per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
counters.Add(new CounterCreationData(
"Save - Written bytes/sec",
"Amount of world-save bytes written to disk per second.",
PerformanceCounterType.RateOfCountsPerSecond32
)
);
#if !MONO
PerformanceCounterCategory.Create( PerformanceCategoryName, PerformanceCategoryDesc, PerformanceCounterCategoryType.SingleInstance, counters );
PerformanceCounterCategory.Create(PerformanceCategoryName, PerformanceCategoryDesc,
PerformanceCounterCategoryType.SingleInstance, counters);
#endif
}
}
numberOfWorldSaves = new PerformanceCounter( PerformanceCategoryName, "Save - Count", false );
numberOfWorldSaves = new PerformanceCounter(PerformanceCategoryName, "Save - Count", false);
itemsPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Items/sec", false );
mobilesPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Mobiles/sec", false );
itemsPerSecond = new PerformanceCounter(PerformanceCategoryName, "Save - Items/sec", false);
mobilesPerSecond = new PerformanceCounter(PerformanceCategoryName, "Save - Mobiles/sec", false);
serializedBytesPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Serialized bytes/sec", false );
writtenBytesPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Written bytes/sec", false );
serializedBytesPerSecond = new PerformanceCounter(PerformanceCategoryName, "Save - Serialized bytes/sec", false);
writtenBytesPerSecond = new PerformanceCounter(PerformanceCategoryName, "Save - Written bytes/sec", false);
// increment number of world saves
numberOfWorldSaves.Increment();
}
// increment number of world saves
numberOfWorldSaves.Increment();
}
public void OnItemSaved( int numberOfBytes ) {
itemsPerSecond.Increment();
public void Dispose()
{
if (!isDisposed)
{
isDisposed = true;
serializedBytesPerSecond.IncrementBy( numberOfBytes );
}
numberOfWorldSaves.Dispose();
public void OnMobileSaved( int numberOfBytes ) {
mobilesPerSecond.Increment();
itemsPerSecond.Dispose();
mobilesPerSecond.Dispose();
serializedBytesPerSecond.IncrementBy( numberOfBytes );
}
serializedBytesPerSecond.Dispose();
writtenBytesPerSecond.Dispose();
}
}
public void OnGuildSaved( int numberOfBytes ) {
serializedBytesPerSecond.IncrementBy( numberOfBytes );
}
public void OnItemSaved(int numberOfBytes)
{
itemsPerSecond.Increment();
public void OnFileWritten( int numberOfBytes ) {
writtenBytesPerSecond.IncrementBy( numberOfBytes );
}
serializedBytesPerSecond.IncrementBy(numberOfBytes);
}
private bool isDisposed;
public void OnMobileSaved(int numberOfBytes)
{
mobilesPerSecond.Increment();
public void Dispose() {
if ( !isDisposed ) {
isDisposed = true;
serializedBytesPerSecond.IncrementBy(numberOfBytes);
}
numberOfWorldSaves.Dispose();
public void OnGuildSaved(int numberOfBytes)
{
serializedBytesPerSecond.IncrementBy(numberOfBytes);
}
itemsPerSecond.Dispose();
mobilesPerSecond.Dispose();
serializedBytesPerSecond.Dispose();
writtenBytesPerSecond.Dispose();
}
}
}
}
public void OnFileWritten(int numberOfBytes)
{
writtenBytesPerSecond.IncrementBy(numberOfBytes);
}
}
}