c# - performance counter: value is zero -


i've decided play performance counters. i'm creating them powershell:

$categoryname = "testlocal"; $categoryhelp = "testlocal"; $categorytype = [system.diagnostics.performancecountercategorytype]::multiinstance;  $categoryexists = [system.diagnostics.performancecountercategory]::exists($categoryname);  if (-not $categoryexists)  {     $objccdc = new-object system.diagnostics.countercreationdatacollection;      $objccd3a = new-object system.diagnostics.countercreationdata;     $objccd3a.countername = "average time per request in db";     $objccd3a.counterhelp = "average time per request in db";     $objccd3a.countertype = "averagetimer32";     $objccdc.add($objccd3a) | out-null;      $objccd3b = new-object system.diagnostics.countercreationdata;     $objccd3b.countername = "average time per request in db base";     $objccd3b.counterhelp = "average time per request in db base";     $objccd3b.countertype = "averagebase";     $objccdc.add($objccd3b) | out-null;      [system.diagnostics.performancecountercategory]::create($categoryname, $categoryhelp, $categorytype, $objccdc) | out-null; } 

and i'm initializing them instance "local".

when i'm calling increment method code, in perfmon.exe app don't see change:

    var processorcategory = performancecountercategory.getcategories().firstordefault(cat => cat.categoryname == "testlocal");     var countersincategory = processorcategory.getcounters("local");      var pc = countersincategory.first(cnt => cnt.countername == "average time per request in db");     var pcbase = countersincategory.first(cnt => cnt.countername == "average time per request in db base");      (int = 0;i>300;i++)     {         pc.incrementby(500);         pcbase.increment();         thread.sleep(200);         pc.incrementby(300);         pcbase.increment();         thread.sleep(200);     }     console.writeline("done"); 

but in perfmon.exe app see 0 time. doing wrong?


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -