npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cwinperfcounter-next

v0.0.21

Published

Class to access Windows performance counters for Node.js

Downloads

1

Readme

cWinPerfCounter

Access Windows performance counters through Node.js.

Getting Started

  1. Install cWinPerfCounter via NPM.

npm install cwinperfcounter

Optionally: rename cwinperfcounter to cWinPerfCounter: npm is unable to handle the complexity of uppercase characters in a module name. Node.js on Windows does not have this problem, so renaming the folder is not required for you to use the module.

  1. Require cWinPerfCounter in your project.

var cWinPerfCounter=require("cWinPerfCounter");

  1. Instantiate cWinPerfCounter for the performance counter you want to read.

var oPerfCounter = new cWinPerfCounter("\\Processor(_Total)\\% Processor Time");

  1. Read values for the requested performance counter.
setInterval(function() {
  try {
    console.log(oPerfCounter.fnGetValue());
  } catch (oError) {
    console.log(oError);
  }
}, 1000);

This particular performance counter will return the average total CPU usage on your machine since the last time it was read. This means it will not return a value the first time you call it, but only after you have called it twice. The try ... catch will handle the error on the first read.

Notes

cWinPerfCounter cross-platform support

cWinPerfCounter comes with pre-build binaries for all supported processor architectures and Node.js versions (ia32 and x64, Node.js v0.9.0 - v0.12.0). These files are stored in separate sub-folders of the bin folder. The index.js attempts to load each .node file for the user's processor architecture until one works. This means it may attempt to load various versions that fail before it will eventually load the right version and return.

Future Node.js versions may be supported, if they can load the addon for the latest version included in this package. If the requirements for compiled addons change in a future version, an additional build of cWinPerfCounter.node will be required.

Building cWinPerfCounter

The build.cmd script will read a list of combinations of processor architecture and Node.js version from "build-targets.txt". It will build a cWinPerfCounter.node file for each of them and store it in its own sub-folder under the "bin" folder. You can also build a .node file for a single processor architecture and Node.js version by providing them as arguments to build.cmd, eg build.cmd x64 0.10.10.

How to find out what performance counters are available

You can either search the web, or you can run "perfmon.exe" on your machine and follow these steps:

  • open Performance -> Monitoring Tools -> Performance Monitor,
  • right-click on the graph and select "Add Counters...",
  • select and add the counters you are interested in, then click "Ok".
  • right-click the graph again and select "Properties...",
  • in the "Data" tab, you will see a list of the names of the performance counters you have selected. You should be able to use these names with cWinPerfCounter.

License

This code is licensed under CC0 v1.0 Universal.