You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
479 B
36 lines
479 B
#include <stdio.h>
|
|
#include <inttypes.h>
|
|
#include <x86intrin.h>
|
|
|
|
|
|
class InstructionCounter
|
|
{
|
|
private:
|
|
unsigned long long counter;
|
|
unsigned long long end_count;
|
|
unsigned long long total_count;
|
|
public:
|
|
|
|
void start()
|
|
{
|
|
counter= __rdtsc();
|
|
};
|
|
|
|
void end()
|
|
{
|
|
end_count = __rdtsc();
|
|
};
|
|
|
|
void print()
|
|
{
|
|
printf("%I64lld \n", getCyclesCount());
|
|
}
|
|
|
|
unsigned long long getCyclesCount()
|
|
{
|
|
end();
|
|
total_count = end_count - counter;
|
|
return total_count;
|
|
}
|
|
};
|