本文整理汇总了C++中Counter::getCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Counter::getCount方法的具体用法?C++ Counter::getCount怎么用?C++ Counter::getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Counter
的用法示例。
在下文中一共展示了Counter::getCount方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupCounter
void KMod::setupCounter(Counter &counter) {
char base[128];
char text[128];
snprintf(base, sizeof(base), "/dev/gator/events/%s", counter.getType());
snprintf(text, sizeof(text), "%s/enabled", base);
int enabled = true;
if (Collector::writeReadDriver(text, &enabled) || !enabled) {
counter.setEnabled(false);
return;
}
snprintf(text, sizeof(text), "%s/key", base);
int key = 0;
Collector::readIntDriver(text, &key);
counter.setKey(key);
snprintf(text, sizeof(text), "%s/event", base);
Collector::writeDriver(text, counter.getEvent());
snprintf(text, sizeof(text), "%s/count", base);
if (access(text, F_OK) == 0) {
int count = counter.getCount();
if (Collector::writeReadDriver(text, &count) && counter.getCount() > 0) {
logg->logError(__FILE__, __LINE__, "Cannot enable EBS for %s:%i with a count of %d\n", counter.getType(), counter.getEvent(), counter.getCount());
handleException();
}
counter.setCount(count);
} else if (counter.getCount() > 0) {
logg->logError(__FILE__, __LINE__, "Event Based Sampling is only supported with kernel versions 3.0.0 and higher with CONFIG_PERF_EVENTS=y, and CONFIG_HW_PERF_EVENTS=y\n");
handleException();
}
}
示例2:
TEST(StatsTest, CounterSimpleTest) {
Counter c;
c.record(-7);
EXPECT_EQ(1, c.getCount());
EXPECT_EQ(-7, c.getMin());
EXPECT_EQ(-7, c.getMax());
EXPECT_EQ(-7.0, c.getAverage());
c.record(-9);
EXPECT_EQ(2, c.getCount());
EXPECT_EQ(-9, c.getMin());
EXPECT_EQ(-7, c.getMax());
EXPECT_EQ(-8.0, c.getAverage());
ostringstream oss;
c.print(oss);
EXPECT_EQ(oss.str(), "2,-8,-9,-7,1");
}
示例3: force_unique
void force_unique() {
if (counter->getCount() > 1) {
counter->decrement();
counter = new Counter();
counter->increment();
Core *new_core = new Core(*(this->core));
this->core = new_core;
}
}
示例4: force_unique
void force_unique() {
if (counter->getCount() > 1) {
char * temp = data;
data = new char[len + 1];
strcpy(data, temp);
counter->decrement();
counter = new Counter();
counter->increment();
}
}
示例5: main
int main()
{
Counter counter;
for(int i=0; i<10; i++)
counter.hit();
sleep(2);
for(int i=0; i<5; i++)
counter.hit();
sleep(3);
cout<<counter.getCount()<<endl;
for(int i=0; i<10; i++)
counter.hit();
sleep(6);
cout<<counter.getCount()<<endl;
sleep(3);
cout<<counter.getCount()<<endl;
return 0;
}
示例6: WinMain
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG oMsg;
float timeNow, timeLast;
Counter *frameCounter = new Counter();
Graphics *engine = new Graphics();
engine->init(hInstance, nCmdShow, 1024, 768);
frameCounter->start();
timeNow = frameCounter->getCount();
timeLast = timeNow;
PeekMessage( &oMsg, NULL, 0, 0, PM_NOREMOVE );
while ( oMsg.message != WM_QUIT )
{
if (PeekMessage( &oMsg, NULL, 0, 0, PM_REMOVE ))
{
TranslateMessage( &oMsg );
DispatchMessage( &oMsg );
}
else
{
timeNow = frameCounter->getCount();
float timeElapsed = (timeNow - timeLast);
if (frameCounter->isValidFPS(30.0))
{
timeLast = timeNow;
engine->run(timeElapsed);
}
}
}
delete engine;
delete frameCounter;
//Release D3D objects
return (int) oMsg.wParam;
}
示例7: setupCounter
void KMod::setupCounter(Counter &counter) {
char base[128];
char text[128];
snprintf(base, sizeof(base), "/dev/gator/events/%s", counter.getType());
snprintf(text, sizeof(text), "%s/enabled", base);
int enabled = true;
if (DriverSource::writeReadDriver(text, &enabled) || !enabled) {
counter.setEnabled(false);
return;
}
int value = 0;
snprintf(text, sizeof(text), "%s/key", base);
DriverSource::readIntDriver(text, &value);
counter.setKey(value);
snprintf(text, sizeof(text), "%s/cores", base);
if (DriverSource::readIntDriver(text, &value) == 0) {
counter.setCores(value);
}
snprintf(text, sizeof(text), "%s/event", base);
DriverSource::writeDriver(text, counter.getEvent());
snprintf(text, sizeof(text), "%s/count", base);
if (access(text, F_OK) == 0) {
int count = counter.getCount();
if (DriverSource::writeReadDriver(text, &count) && counter.getCount() > 0) {
logg->logError(__FILE__, __LINE__, "Cannot enable EBS for %s:%i with a count of %d\n", counter.getType(), counter.getEvent(), counter.getCount());
handleException();
}
counter.setCount(count);
} else if (counter.getCount() > 0) {
ConfigurationXML::remove();
logg->logError(__FILE__, __LINE__, "Event Based Sampling is only supported with kernel versions 3.0.0 and higher with CONFIG_PERF_EVENTS=y, and CONFIG_HW_PERF_EVENTS=y. The invalid configuration.xml has been removed.\n");
handleException();
}
}
示例8: setupCounter
void PerfDriver::setupCounter(Counter &counter) {
PerfCounter *const perfCounter = findCounter(counter);
if (perfCounter == NULL) {
counter.setEnabled(false);
return;
}
// Don't use the config from counters XML if it's not set, ex: software counters
if (counter.getEvent() != -1) {
perfCounter->setConfig(counter.getEvent());
}
perfCounter->setCount(counter.getCount());
perfCounter->setEnabled(true);
counter.setKey(perfCounter->getKey());
}
示例9: main
int main(int argc, char const *argv[]) {
Counter count1(10);
Counter count2(12);
Counter megaCount = count1 + count2;
cout << "count1: " << count1.getCount() <<\
"\ncount2: " << count2.getCount() <<\
"\nmegaCount: " << megaCount.getCount() << endl;
if ((++count1).getCount() > 10) {
cout << "count1 is greater than 10!" << endl;
}
if ((count2++).getCount() == 12) {
cout << "Check out what count2 is: " << count2.getCount() << endl;
}
return 0;
}
示例10: task1
void task1(void *pvParameters)
{
Counter local_counter = Counter(12);
Counter *new_counter = new Counter(24);
while(1) {
Counter *counter = NULL;
switch(rand() % 3) {
case 0:
counter = &local_counter;
break;
case 1:
counter = &static_counter;
break;
default:
counter = new_counter;
break;
}
counter->Increment();
printf("local counter %d static counter %d newly allocated counter %d\r\n", local_counter.getCount(),
static_counter.getCount(), new_counter->getCount());
vTaskDelay(100);
}
}
示例11: newCount
Counter Counter::operator+(Counter rhs) {
Counter newCount(this -> getCount() + rhs.getCount());
return newCount;
}
示例12: getCount
int getCount() {return counter.getCount();}