void FireflyOptimizator::run() { optmized = false; beta = 1.0; ranks.clear(); ranks.resize(population.size()); markers.clear(); markers.resize(population.size()); vector<Segmentation>::iterator ffI; int idx_ffI =0; for (gen = 1; gen <= MaxGenerations; gen++) { cout<<">>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<"<<endl; cout<<"GENERATION "<<gen<<endl; cout<< "Starting generation. Updating population "; startClock(); startGeneration(); endClock(); cout << " - end ( "<< elapsed_secs<< " sec )" << endl; for( ffI = population.begin(),idx_ffI=0; ffI != population.end(); idx_ffI++,ffI++) { startClock(); computeFirefly(*ffI,idx_ffI); endClock(); cout << " - end ( "<< elapsed_secs<< " sec )" << endl; } cout<< "Generation done. Updating population "; startClock(); updateGeneration(); endClock(); cout<< " - OK "<<" ( "<< elapsed_secs << " sec )" << endl;; finishGeneration(); } cout<<"Final result "<<(generationBest.end()-1)->second<<endl; optmized = true; }
int layout_test_simple(struct dm_disk_if *d) { int i, lbn, count = 0, runlbn = 0; struct dm_pbn pbn, trkpbn = {0,0,0}; int bad = 0; for(i = 0; i < d->dm_sectors; i++) { int lbn2; dm_angle_t skew, zerol; struct dm_mech_state track; dm_ptol_result_t rc; startClock(0); rc = d->layout->dm_translate_ltop(d, i, MAP_FULL, &pbn, 0); stopClock(0); if(rc == DM_NX) { printf("*** %s %d -> NX\n", __func__, i); bad++; continue; } startClock(1); lbn2 = d->layout->dm_translate_ptol(d, &pbn, 0); stopClock(1); if(lbn2 == DM_NX) { printf("*** layout_test_simple %d -> (%d,%d,%d) -> NX\n", i, pbn.cyl, pbn.head, pbn.sector); bad++; continue; } if(i != lbn2) { printf("*** layout_test_simple: %8d -> (%8d, %3d, %4d) -> %8d\n", i, pbn.cyl, pbn.head, pbn.sector, lbn2); bad++; } else { // printf("%8d <-> (%8d, %3d, %4d)\n", // c, pbn.cyl, pbn.head, pbn.sector); if((lbn2 > 0) && (trkpbn.head == pbn.head) && (trkpbn.cyl == pbn.cyl) && ((trkpbn.sector+count) == pbn.sector)) { count++; } else { // printf("l %d %d %d %d %d\n", runlbn, trkpbn.cyl, trkpbn.head, trkpbn.sector, count); runlbn = i; trkpbn = pbn; count = 1; } } fflush(stdout); } return bad; }
int main(int argc, char **argv) { long l, limit = 8 * 1024 * 1024, size = 1; int zero = open("/dev/zero", O_RDONLY); // file descriptor if (argc > 2) limit = strtol(argv[2], 0, 0); if (argc > 1) size = strtol(argv[1], 0, 0); char *buffer = (char *)malloc(size * sizeof(char)); printf("Timing read()\n"); volatile long x = 0; startClock(); for (l = 0; l < limit; l += size) { read(zero,buffer,size); x += size; } endClock(); if (x != (limit / size) * size) printf("Got the wrong answer\n"); printf("%ld invocations of read(%ld) took: %ld usec\n", (limit / size), size, usecClock()); close(zero); free(buffer); return 0; }
int main(int argc, char **argv) { long l, limit = LIMIT, size = 1; FILE *fnull = fopen("/dev/null", "wb"); FILE *fzero = fopen("/dev/zero", "rb"); int null = open("/dev/null", O_WRONLY); int zero = open("/dev/zero", O_RDONLY); if (argc > 2) limit = strtol(argv[2], 0, 0); if (argc > 1) size = strtol(argv[1], 0, 0); char *buffer = (char *)malloc(size * sizeof(char)); printf("Timing nothing\n"); volatile long x = 0; startClock(); for (l = 0; l < limit; l += size) { x += size; } endClock(); if (x != (limit / size) * size) printf("Got the wrong answer\n"); printf("%ld invocations of nothing(%ld) took: %ld usec\n", (limit / size), size, usecClock()); close(null); close(zero); fclose(fnull); fclose(fzero); free(buffer); return 0; }
void MainWindow::startTracking() { startClock(); QPushButton *trackBtn = getTrackBtn(); trackBtn->setText("Stop"); trackingClock->start(); }
bool RTCx::setClock(const struct tm *tm, timeFunc_t func) const { // Find which register to read from uint8_t sz = 0; uint8_t reg = getRegister(func, sz); if (sz == 0) return false; // not supported if (func == TIME) stopClock(); uint8_t osconEtc = 0; if (device == MCP7941x) // Preserve OSCON, VBAT, VBATEN on MCP7941x osconEtc = readData((uint8_t)0x03) & 0x38; // Write everything *except* the second Wire.beginTransmission(address); Wire.write(reg + 1); Wire.write(decToBcd(tm->tm_min)); Wire.write(decToBcd(tm->tm_hour)); // Forces 24h mode Wire.write(decToBcd(tm->tm_wday + 1) | osconEtc); Wire.write(decToBcd(tm->tm_mday)); Wire.write(decToBcd(tm->tm_mon + 1)); // leap year read-only on MCP7941x Wire.write(decToBcd(tm->tm_year % 100)); Wire.endTransmission(); if (func == TIME) startClock(decToBcd(tm->tm_sec)); else writeData(reg, decToBcd(tm->tm_sec)); return true; }
Clock::Clock(const Clock& c) : started(c.started), paused(c.paused), FRAME_CAP_ON(c.FRAME_CAP_ON), PERIOD(c.PERIOD), frames(c.frames), timeAtStart(c.timeAtStart), timeAtPause(c.timeAtPause), currTicks(c.currTicks), prevTicks(c.prevTicks), ticks(c.ticks) { startClock(); }
void RTCx::clearVBAT(void) const { if (device == MCP7941x) { stopClock(); uint8_t d = readData((uint8_t)0x03); d &= 0xef; writeData((uint8_t)0x03, d); uint8_t s = readData((uint8_t)0); startClock(s); } }
Clock::Clock() : started(false), paused(false), FRAME_CAP_ON(Gamedata::getInstance().getXmlBool("frameCapOn")), PERIOD(Gamedata::getInstance().getXmlInt("period")), frames(0), timeAtStart(0), timeAtPause(0), currTicks(0), prevTicks(0), ticks(0) { startClock(); }
void Clock::configure() { ConfigureDialog dlg; dlg.setShowSecondsHand(mShowSeconds); if (dlg.exec()) { mShowSeconds = dlg.showSecondsHand(); startClock(); update(); } save(); }
void RTCx::enableBatteryBackup(bool enable) const { if (device == MCP7941x) { stopClock(); uint8_t d = readData((uint8_t)0x03); if (enable) d |= 0x08; else d &= 0xf7; writeData((uint8_t)0x03, d); uint8_t s = readData((uint8_t)0); startClock(s); } }
Clock::Clock(QGraphicsScene * scene, const QString & configId, RazorSettings * config) : DesktopWidgetPlugin(scene, configId, config) { config->beginGroup(configId); mShowSeconds = config->value("showseconds", false).toBool(); config->endGroup(); mClockPix = new QPixmap(":/imgs/clock.png"); mCenterPix = new QPixmap(":/imgs/center.png"); mHourPix = new QPixmap(":/imgs/hour.png"); mMinutePix = new QPixmap(":/imgs/minute.png"); mSecondsPix = new QPixmap(":/imgs/seconds.png"); mTimerId = 0; startClock(); }
Clock::Clock(ClockPlugin *parent, const QString & configId, LxQt::Settings * config) : QGraphicsWidget(parent), m_parent(parent) { config->beginGroup(configId); mShowSeconds = config->value("showseconds", false).toBool(); config->endGroup(); mClockPix = new QPixmap(":/imgs/clock.png"); mCenterPix = new QPixmap(":/imgs/center.png"); mHourPix = new QPixmap(":/imgs/hour.png"); mMinutePix = new QPixmap(":/imgs/minute.png"); mSecondsPix = new QPixmap(":/imgs/seconds.png"); mTimerId = 0; startClock(); }
void ChessPlayer::go() { if (m_state == Disconnected) return; setState(Thinking); disconnect(this, SIGNAL(ready()), this, SLOT(go())); if (!isReady()) { connect(this, SIGNAL(ready()), this, SLOT(go())); return; } Q_ASSERT(m_board != nullptr); m_side = m_board->sideToMove(); startClock(); startThinking(); }
MainWorker::MainWorker() : _sensorsIface(DALL_PORT), _sensors(_sensorsIface), _network(_sensors, HWdata, _mainbuf) { init(); HWdata.pinsSetup(); startClock(); _iface = &_sensorsIface; lcd_init(LCD_DISP_ON); lcd_led(0); debugSDcardLog.begin(); debug(F("-------Hello-------\r\n")); _sensorsIface.DS2480B_Detect(); debugSDcardLog.end(); /*** todo for debug ***/ // _mainbuf[0] = "28:2F:15:F5:04:00:00:4C"; // _mainbuf[1] = "28:41:14:70:03:00:00:73"; /**********************/ loadMainbuff(); #ifdef LEVEL_INFO uint16_t i = 0; INFO(F("Sensor ROMs in memory:")); for (; ((!_mainbuf[i].isNull()) && (i < ROM_MAINBFF_SIZE)); i++) { debug(_mainbuf[i].toString()); debug("\r\n"); } char buff[10]; sprintf(buff, "count: %d", i); debug(buff); debug("\r\n"); #endif }
//___________________________________________________________________ bool StackedWidgetData::initializeAnimation( void ) { // check enability if ( !( target_ && target_.data()->isVisible() ) ) { return false; } // check index if ( target_.data()->currentIndex() == index_ ) { return false; } // do not animate if either index or currentIndex is not valid // but update index_ none the less if ( target_.data()->currentIndex() < 0 || index_ < 0 ) { index_ = target_.data()->currentIndex(); return false; } // get old widget (matching index_) and initialize transition if ( QWidget* widget = target_.data()->widget( index_ ) ) { transition().data()->setOpacity( 0 ); startClock(); transition().data()->setGeometry( widget->geometry() ); transition().data()->setStartPixmap( transition().data()->grab( widget ) ); index_ = target_.data()->currentIndex(); return !slow(); } else { index_ = target_.data()->currentIndex(); return false; } }
void Tresenv::sim_step() { // implement graceful exit when Ctrl-C is hit during simulation. We want // to finish the current event, then normally exit via callFinish() etc // so that simulation results are not lost. installSignalHandler(); startClock(); sigint_received = false; disable_tracing = true; cSimpleModule *mod; try { mod = simulation.selectNextModule(); if (!mod) throw cTerminationException("scheduler interrupted while waiting"); // execute event simulation.doOneEvent(mod); printEventBanner(mod); checkTimeLimits(); if (sigint_received) throw cTerminationException("SIGINT or SIGTERM received, exiting"); } catch (std::exception& e) { disable_tracing = false; stoppedWithException(e); displayException(e); } disable_tracing = false; stopClock(); deinstallSignalHandler(); }
void initTimer(void) { registerISR(8, timerISR); /* register ISR i vector table */ setClock(50,40); /* set clock to 200ms */ startClock(); /* start clock */ }
TimerManager::TimerManager(Stack* documents, QWidget* parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), m_documents(documents) { setWindowTitle(tr("Timers")); // Set up interaction with timer display m_display = new TimerDisplay(m_timers, this); m_display->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_display, SIGNAL(clicked()), this, SLOT(toggleVisibility())); connect(m_display, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(recentTimerMenuRequested(const QPoint&))); // Create clock m_clock_label = new QLabel(this); m_clock_label->setAlignment(Qt::AlignCenter); m_clock_timer = new QTimer(this); m_clock_timer->setInterval(1000); connect(m_clock_timer, SIGNAL(timeout()), this, SLOT(updateClock())); startClock(); // Create timers layout QWidget* timers_widget = new QWidget(this); m_timers_layout = new QVBoxLayout(timers_widget); m_timers_layout->addStretch(); m_timers_layout->setSizeConstraint(QLayout::SetMinAndMaxSize); m_timers_area = new QScrollArea(this); m_timers_area->setWidget(timers_widget); m_timers_area->setWidgetResizable(true); // Create action buttons QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this); connect(buttons, SIGNAL(rejected()), this, SLOT(close())); m_new_button = buttons->addButton(tr("New"), QDialogButtonBox::ActionRole); m_new_button->setDefault(true); connect(m_new_button, SIGNAL(clicked()), this, SLOT(newTimer())); m_recent_timers = new QMenu(this); m_recent_button = buttons->addButton(tr("Recent"), QDialogButtonBox::ActionRole); m_recent_button->setMenu(m_recent_timers); setupRecentMenu(); connect(m_recent_timers, SIGNAL(triggered(QAction*)), this, SLOT(recentTimer(QAction*))); // Lay out window QVBoxLayout* layout = new QVBoxLayout(this); layout->addWidget(m_clock_label); layout->addWidget(m_timers_area, 1); layout->addWidget(buttons); setMinimumHeight(sizeHint().width()); QSettings settings; settings.beginGroup("Timers"); resize(settings.value("DialogSize").toSize()); // Load currently running timers QStringList ids = settings.childKeys(); foreach (const QString& id, ids) { int i = id.mid(5).toInt(); if (!id.startsWith("Timer") || i == 0) { continue; } Timer* timer = new Timer(id, m_documents, this); addTimer(timer); timerChanged(timer); }
int Detector::detectFaces(ClassifierInterface* ci, const std::string img_path, double ac, int draw, int save){ SubwindowGenerator sg(img_path,_wr,_shift_step); IntegralImage ii(img_path); startClock(); ulong total_sw,total_faces; std::vector<Subwindow> lista = sg.generateSubwindows(_ng); stopClock("Generating Windows"); total_faces=0; total_sw = lista.size(); int res; int cur_gen=-1; std::vector<int*> faces_boxes; std::vector<int*> scenes_boxes; startClock(); for(register int i=0;i<lista.size();++i){ // printf("NEW SUBWINDOW\n"); if(cur_gen!=lista[i]._cur_ng){ ci->resize(lista[i]._ce); cur_gen = lista[i]._cur_ng; } if(ac<0){ res = ci->isFace(ii,(lista[i])); }else{ res = ci->isFace(ii,(lista[i]),ac); } if(res==1){ faces_boxes.push_back(new int[4]); lista[i].cropBox( faces_boxes[faces_boxes.size()-1] ); total_faces+=1; }else{ scenes_boxes.push_back(new int[4]); lista[i].cropBox( scenes_boxes[scenes_boxes.size()-1] ); } } stopClock("Detection Time"); if(draw==1){ int** boxes_array = (int**) malloc(faces_boxes.size()*sizeof(int*)); for(register int i=0;i<faces_boxes.size();i++){ boxes_array[i] = faces_boxes[i]; } std::string save_path = Config::PROJECT_PATH + "/analysis/detector_output/img_det.pgm"; drawRectangles(img_path.c_str(),faces_boxes.size(),boxes_array,"white", save, save_path.c_str() ); free(boxes_array); // int** boxes_array = (int**) malloc(scenes_boxes.size()*sizeof(int*)); // for(register int i=0;i<scenes_boxes.size();i++){ // boxes_array[i] = scenes_boxes[i]; // } // drawRectangles(img_path.c_str(),scenes_boxes.size(),boxes_array,"red"); // free(boxes_array); } printf("\nSW: %lu FACES: %lu\n",total_sw,total_faces); return total_faces; }
void TimeManager::resetClock(const string clock_name) { killClock(clock_name); startClock(clock_name); }
CounterSubsystem &stopClock( int counterBlock ) { startClock( counterBlock, 0 ); return *this; } // stopClock()