0
我有一個WCF服務的負載測試,我們正在嘗試不同的壓縮庫和配置,我們需要測量測試期間發送的mb總數。是否有衡量相對交通公關的績效指標?測試。如果是這樣,我如何將它添加到我的負載測試中 - 似乎只有部分性能計數器可見 - 例如,在「Web服務」類別下,我沒有在VS負載測試中看到性能計數器「收到總字節數」,但我可以在PerfMon中找到它。VS負載測試和'發送總字節'性能計數器?
感謝
我有一個WCF服務的負載測試,我們正在嘗試不同的壓縮庫和配置,我們需要測量測試期間發送的mb總數。是否有衡量相對交通公關的績效指標?測試。如果是這樣,我如何將它添加到我的負載測試中 - 似乎只有部分性能計數器可見 - 例如,在「Web服務」類別下,我沒有在VS負載測試中看到性能計數器「收到總字節數」,但我可以在PerfMon中找到它。VS負載測試和'發送總字節'性能計數器?
感謝
在負載測試擴大計數器集>展開適用>右鍵點擊計數器集>添加計數器
您可以實現自己的自定義性能計數器,像這樣:
using System;
using System.Diagnostics;
using System.Net.NetworkInformation;
namespace PerfCounter
{
class PerfCounter
{
private const String categoryName = "Custom category";
private const String counterName = "Total bytes received";
private const String categoryHelp = "A category for custom performance counters";
private const String counterHelp = "Total bytes received on network interface";
private const String lanName = "Local Area Connection"; // change this to match your network connection
private const int sampleRateInMillis = 1000;
private const int numberofSamples = 200000;
private static NetworkInterface lan = null;
private static PerformanceCounter perfCounter;
private static long initialReceivedBytes;
static void Main(string[] args)
{
setupLAN();
setupCategory();
createCounters();
updatePerfCounters();
}
private static void setupCategory()
{
if (!PerformanceCounterCategory.Exists(categoryName))
{
CounterCreationDataCollection counterCreationDataCollection = new CounterCreationDataCollection();
CounterCreationData totalBytesReceived = new CounterCreationData();
totalBytesReceived.CounterType = PerformanceCounterType.NumberOfItems64;
totalBytesReceived.CounterName = counterName;
counterCreationDataCollection.Add(totalBytesReceived);
PerformanceCounterCategory.Create(categoryName, categoryHelp, PerformanceCounterCategoryType.MultiInstance, counterCreationDataCollection);
}
else
Console.WriteLine("Category {0} exists", categoryName);
}
private static void createCounters()
{
perfCounter = new PerformanceCounter(categoryName, counterName, false);
perfCounter.RawValue = getTotalBytesReceived();
}
private static long getTotalBytesReceived()
{
return lan.GetIPv4Statistics().BytesReceived;
}
private static void setupLAN()
{
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface networkInterface in interfaces)
{
if (networkInterface.Name.Equals(lanName))
lan = networkInterface;
}
initialReceivedBytes = lan.GetIPv4Statistics().BytesReceived;
}
private static void updatePerfCounters()
{
for (int i = 0; i < numberofSamples; i++)
{
perfCounter.RawValue = getTotalBytesReceived();
Console.WriteLine("received: {0} bytes", perfCounter.RawValue - initialReceivedBytes);
System.Threading.Thread.Sleep(sampleRateInMillis);
}
}
}
}
嗯,猜不多需要這些信息... – jaspernygaard