I am working on full and sparse matrix library in C++.
I have some code that I could begin to optimize a little. Therefore I need performance counter.
I have found some useful posts and solutions for Windows, but for short period computations.
What I need is a counter that will work on Linux and Windows (using preprocessor macros is ok to choose instructions for lin or win within compilation).
But what is more important, it should measure wide variety of times.
To test some small parts of code I would need resolution about 1 ms (like in QueryPerformance functions), but for greater tasks it should be able to measure time with lets say 1 s resolution, but those computations may take even a week or so.
I have compeletly no idea how to create something lke that.
If you mean "performance counter" as in "using hardware performance counters" I cannot help, but if you want just doing performance monitoring, I'd suggest using pintool (here), that let's you instrument application at a wide variety of levels, and using something like gettimeofday to keep track of the time
How about just calling rdtsc from an asm block (code on wiki for Linux and Windows)? Since you just want relative times, you don't even have to do the unit normalization math. Should be accurate to well under a microsecond, and there shouldn't be any clock related issues unless you are running a really old PC.
I just want to keep things simple. For Altlas I would need to compile it, tune it and so on... also change BIOS settings if necessary. And i am writing matrix lib for non-programmers really but for ppl who use programming just to solve some math problems. I don't want them to be forced to build Atlas for example, move it to Windows, cross compile sometimes and so on :]