c# - How to get the unit of a specific performance counter -


i reading different data cpu usage via system.diagnostics.performancecounter class. after i'd output values , unit associated counter (ex. mb or gb memory).

is there way query unit value of performance counter has?

look @ countername property , and inside string (mbytes or kbytes) if not found bytes. let know scale of counter (vb.net)

if instr(somecounter.countername.tolower , "mbytes")       blah blah elseif instr(somecounter.countername.tolower , "kbytes")      blah blah elseif instr(somecounter.countername.tolower , "bytes")      blah blah else      blah blah end if 

or

dim scale string = "" dim xpos integer = instr(somecounter.countername.tolower, "bytes") 

grab char before , trim remove space in front if otherwise return scale

if xpos>1     scale=strings.mid(somecounter.countername.tolower, xpos-1, 6).trim elseif xpos=1     

the first word of countername if bytes

   scale="bytes" else    scale="something else" end if  

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -