本文整理汇总了C++中Counter::getEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ Counter::getEvent方法的具体用法?C++ Counter::getEvent怎么用?C++ Counter::getEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Counter
的用法示例。
在下文中一共展示了Counter::getEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: 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();
}
}
示例3: 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();
}
}