Application counters in Linux? (and OSX?)

后端 未结 1 1394
旧时难觅i
旧时难觅i 2021-02-07 15:38

I\'m trying to figure out if there is a library that gives me something near the equivalent of Windows custom performance counters (described here http://geekswithblogs.net/.NET

1条回答
  •  野的像风
    2021-02-07 16:22

    In addition to @user964970 comment/solution, I suggest making it OS agnostic.

    Use an OS agnostic API, like ACE or BOOST, to create your own library, supplying a named-semaphore write-protected-counter, placed inside a named-shared-memory segment.

    This should be your library's API :

    long * createCounter(const char * name); // Create a counter
                                             // Will create a named semaphore and a named
                                             // shared memory segment, holding the counter     
                                             // value. Will return pointer to counter
    long * getCounter(const char * name); // Get existing counter pointer
                                          // in the calling process' address space
    long incCounter(const char * name);   // increment existing counter
    

    0 讨论(0)
提交回复
热议问题