标签: performancecounter

跨越不同性能计数器的性能计数器实例

我看到的是,我的性能计数器实例被添加到超出指定计数器的性能类别中的其他计数器。

在此处输入图片说明

鉴于以下代码:

using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApplication26
{
    class Program
    {
        static void Main(string[] args)
        {
            string category = "Foo";
            string categoryHelp = "Test counters";
            string fooCounter1Name = "Test Foo counter 1";
            string fooCounter1InstanceName = fooCounter1Name + "Instance";
            string fooCounter2Name = "Test Foo counter 2";
            string fooCounter2InstanceName = fooCounter2Name + "Instance";

            if (PerformanceCounterCategory.Exists(category))
                PerformanceCounterCategory.Delete(category);

            var counterCreationDataCollection = new CounterCreationDataCollection();
            counterCreationDataCollection.Add(new CounterCreationData(fooCounter1Name, "", PerformanceCounterType.RateOfCountsPerSecond64));
            counterCreationDataCollection.Add(new CounterCreationData(fooCounter2Name, "", PerformanceCounterType.RateOfCountsPerSecond64));

            PerformanceCounterCategory.Create(category, categoryHelp, PerformanceCounterCategoryType.MultiInstance, counterCreationDataCollection);

            PerformanceCounter fooCounter1Instance = new …
Run Code Online (Sandbox Code Playgroud)

c# performancecounter

4
推荐指数
1
解决办法
1028
查看次数

性能计数器实例名称与进程名称

我正在连接到该Process类别中的各种性能计数器.我使用以下c#方法来确定获取计数器时要使用的实例名称:

private const string _categoryName = "Process";
private const string _processIdCounter = "ID Process";

public static bool TryGetInstanceName(Process process, out string instanceName)
{
    PerformanceCounterCategory processCategory = new PerformanceCounterCategory(_categoryName);
    string[] instanceNames = processCategory.GetInstanceNames();
    foreach (string name in instanceNames)
    {
        using (PerformanceCounter processIdCounter = new PerformanceCounter(_categoryName, _processIdCounter, name, true))
        {
            if (process.Id == (int)processIdCounter.RawValue)
            {
                instanceName = name;
                return true;
            }
        }
    }

    instanceName = null;
    return false;
}
Run Code Online (Sandbox Code Playgroud)

现在,我注意到返回的实例名称通常与值相匹配Process.ProcessName.

实例名称和进程名称如何相关?

我问,因为我想简化foreach例程中的循环,这样我就不必获取ID Process …

c# process performancecounter

4
推荐指数
1
解决办法
3847
查看次数

Chrome 开发者工具分析器显示不同数量的方法调用与 console.log

我在 Chrome 中使用开发工具的配置文件选项卡。在配置文件中,我看到一个resizeDocument名为 6+ 次的函数条目,值为 113ms、17ms、45ms 等。相同的行号、相同的文件、相同的所有内容。

当我从控制台内部resizeDocument函数登录时,我只能得到一个条目。到底是怎么回事?

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

javascript google-chrome performancecounter google-chrome-devtools

4
推荐指数
1
解决办法
914
查看次数

QueryPerformanceCounter或GetSystemTimePreciseAsFileTime使用SNTP时?

以下段落让我困惑:

从文章:获取高分辨率时间戳

当您需要分辨率为1微秒或更高的时间戳并且您不需要将时间戳同步到外部时间参考时,请选择QueryPerformanceCounter,KeQueryPerformanceCounter或KeQueryInterruptTimePrecise.如果需要分辨率为1微秒或更高的UTC同步时间戳,请选择GetSystemTimePreciseAsFileTime或KeQuerySystemTimePrecise.

短语" 要与外部时间参考同步 "在这里意味着什么?我学到的是这个:

  1. 如果您的PC未连接到GPS(通过串行端口或SNTP),请使用QueryPerformanceCounter.
  2. 如果PC已连接,则使用GetSystemTimePreciseAsFileTime.

这个假设是否正确?

performancecounter

4
推荐指数
2
解决办法
1426
查看次数

Python 2.x - Windows上的QueryPerformanceCounter()

我想用Python编写自己的时钟对象.我希望它非常非常准确.我在Windows上看到,我可以使用QueryPerformanceCounter().但是怎么样?我不知道任何C; 只有Python 2.x.

有人可以给我一个提示,如何在Python中使用它来在Win上制作一个准确的时钟吗?

python windows time clock performancecounter

4
推荐指数
1
解决办法
880
查看次数

ASP.NET和输出缓存 - 如何查看它是否正常工作?

问题:我有一个ASP.NET网站,我不相信我的代码正确地获得OutputCached.我正在使用IIS7性能计数器向我显示点击或错过一秒钟.


我有一个简单的ASP.NET MVC网站.我正在使用内置的ASP.NET输出缓存魔术.

这是一些示例代码: -

[AcceptVerbs(HttpVerbs.Get)]
[ApiAuthorize]  // <-- this checks the querystring for a "key=1234". 
                // Doesn't find it, then it throws a 401 NOT AUTH exception.
[OutputCache(CacheProfile = "HomeController_Foo")]
public ActionResult Foo(string name, byte? alpha, byte? beta)
{
}
Run Code Online (Sandbox Code Playgroud)

所以这意味着每个网址查询可以如下所示: -

现在,请注意我是如何让OutputCache引用配置文件的?这里是...

<caching>
    <outputCacheSettings>
        <outputCacheProfiles>
            <add name="HomeController_Foo" duration="3600" varyByParam="key;name;alpha;beta"/>
        </outputCacheProfiles>
    </outputCacheSettings>
</caching>
Run Code Online (Sandbox Code Playgroud)

没什么太难的......

所以这里是踢球者!当我通过使用IIS7性能计数器确认发生这种情况时,它表示输出缓存未命中/秒是我正在进行的请求的100%.输出缓存命中数为0 /秒.

我正在使用第三方Web负载压力测试程序来查询我的网站.现在,源数据是什么?名单.程序循环遍历所有名称,然后返回到开始,冲洗重复.因此,至少调用一次相同的查询字符串是有限的.IIS日志文件确认了这一点.

我没有传递alpha或beta的任何数据.

这是我的查询字符串我正在打....

...我继续使用数据源文件中的名称替换'hello + world',并且IIS日志确认了这一点.

那么..我在看错了性能指标吗?有没有其他技巧可以看出它是否正在获得输出缓存?代码非常快,因此很难判断这是否是缓存结果.

asp.net performance outputcache performancecounter

3
推荐指数
1
解决办法
4107
查看次数

了解运行代码内时间计数器和外部代码时间计数器之间的区别

好.这个qiestion的标题不容易解码,但让我解释一下.

为了建立一个共同点,我将提供一些详细信息,但这个问题适用于所有可能的上下文,语言和平台.

平台:.NET Framework 4.0系统:Windows(显然)语言:F#

我需要运行一个程序并评估执行某些指令所花费的时间.考虑有一个主要功能,你在那里放置一个时间计数器:

open System.Diagnostics
let main args =
   let watch = new Stopwatch ()
   watch.Start ()
   (* Calling functions and executing main body... *)
   watch.Stop ()
   (* Printing out the evaluated time *)
Run Code Online (Sandbox Code Playgroud)

好!我有时间,我很开心.

现在我想衡量这个时间,但是从外面评估它.因此,请考虑运行该文件但同时计算时间的PowerShell脚本:

$MyProcess = New-Object "System.Diagnostics.Process";
$Watch = New-Object "System.Diagnostics.Stopwatch";
$MyProcess.StartInfo.FileName = "Myexec";
$MyProcess.StartInfo.Arguments = "args";
$MyProcess.StartInfo.CreateNoWindow = $true;
$MyProcess.StartInfo.UseShellExecute = $false;
$StartingTimer = $Watch.Start(); # Starts the timer
$StartingProcess = $MyProcess.Start();
$WaitingForExit = $MyProcess.WaitForExit();
$StoppingTimer = $Watch.Stop(); # Stops the timer
# …
Run Code Online (Sandbox Code Playgroud)

.net powershell performance time performancecounter

3
推荐指数
1
解决办法
179
查看次数

为什么我需要管理员来阅读.NET CLR内存性能计数器

我无法以编程方式(在c#中)找到".NET CLR Memory"计数器类别,就像在这个问题中一样.以管理员身份运行解决了问题.

但为什么我需要这样做呢?还有其他选择吗?我想要只读访问,在我的应用程序中查看GC生成集合以进行性能分析.最好不必使用管理员权限运行应用程序.

编辑:

  • 我可以在性能监视器工具中看到内存性能计数器,而无需以管理员身份运行
  • 如果不以Admin身份运行,我可以通过编程方式获得一个缩短(但不是空)的性能计数器类别列表,但这不包括我感兴趣的那个.
  • 我们的公司设置有点疯狂:我有管理员权限,但我不是本地管理员组的成员.我确实有权添加自己,但每30分钟左右一些自动化过程会删除我.不知道这是否会影响任何事情
  • 将自己添加到性能监视器用户组没有任何效果(除非我需要先重启)

.net c# performancecounter

3
推荐指数
2
解决办法
1184
查看次数

PerformanceCounter报告的CPU使用率高于观察到的CPU使用率

我现在正在这样做:

PerformanceCounter cpuUsage = new PerformanceCounter("Processor", "% Processor Time", "_Total");
cpuUsage.NextValue();
System.Threading.Thread.Sleep(1000);
RV = cpuUsage.NextValue();
Run Code Online (Sandbox Code Playgroud)

我定期调用该函数以获得CPU使用率.当我在TaskManager中监视系统时,PerformanceCounter报告的CPU使用率始终比TaskManager报告的高出15-20%(TaskManager中的30%=来自PerformanceCounter的50%).

也许有我忽略的文档,但有没有人有解释?也许它检查的瞬间CPU使用率更高,任务管理器报告平均值?

c# performancecounter cpu-usage

3
推荐指数
1
解决办法
2076
查看次数

创建性能计数器PowerShell:指定的类别的计数器布局无效

我正在尝试使用PowerShell创建性能计数器,但由于我使用了AverageCount64,我收到以下错误:

"指定类别的计数器布局无效,类型的计数器:AverageCount64,AverageTimer32,CounterMultiTimer,CounterMultiTimerInverse,CounterMultiTimer100Ns,CounterMultiTimer100NsInverse,RawFraction或SampleFraction必须紧跟任何基本计数器类型:AverageBase,CounterMultiBase, RawBase或SampleBase."

我知道我需要为AverageCount64类型添加AverageBase但不确定如何在我的代码中添加它,特别是因为我有不需要AverageBase的类型(RateOfCountsPerSecond64):

    $AnalyticsCollection = New-Object System.Diagnostics.CounterCreationDataCollection
    $AnalyticsCollection.Add( (New-Object $ccdTypeName "Aggregation | Total Aggregation Errors / sec", "The total number of interactions which could not be aggregated due to an exception.", RateOfCountsPerSecond64) )    
    $AnalyticsCollection.Add( (New-Object $ccdTypeName "Aggregation | Average Check Out Time - History (ms)", "Average time it takes to obtain a work item from a range scheduler while rebuilding the reporting database.", AverageCount64) )
    $AnalyticsCollection.Add( (New-Object $ccdTypeName "Collection | Total Visits / sec", "The total number of visits …
Run Code Online (Sandbox Code Playgroud)

powershell performancecounter

3
推荐指数
1
解决办法
456
查看次数