Пример #1
0
long long benchmark(int nElements, int itrNum , void(*myfn)()){
	n = m = p = nElements;
	a = (int**) malloc(sizeof(int*)*nElements);
	b = (int**) malloc(sizeof(int*)*nElements);
	c = (int**) malloc(sizeof(int*)*nElements);

	int i,j,k;
	long long averagetime =0 ,t1,t2;
	for (i = 0; i < nElements; ++i){
		a[i] = (int*) malloc(sizeof(int)*nElements); 
		b[i] = (int*) malloc(sizeof(int)*nElements);
		c[i] = (int*) malloc(sizeof(int)*nElements);
	}
	for (k = 0; k < itrNum; ++k) {
		for (i = 0; i < nElements; ++i)
			for (j = 0; j < nElements; ++j)
				a[i][j] =rand()%1001 , b[i][j] =rand()%1001;

		t1 = curTime();
//		multiply1();
		(*myfn)();
		t2 = curTime();
		averagetime += (t2-t1);
	}

	print(c,nElements,nElements);
	averagetime/=itrNum;
	printf("benchmark using a[%d][%d] * b[%d][%d]: average on %d samples = %lld usec\n",
			nElements,nElements,nElements,nElements,itrNum,averagetime);
	return averagetime;
}
Пример #2
0
template <typename Container> void timed_tester(const std::vector<int> &il) {
    for (auto i : il) {
        auto start = curTime();
        tester<Container>(i);
        auto stop = curTime();
        auto tn(abi::__cxa_demangle(typeid(Container).name(), 0, 0, nullptr));
        std::cout << tn << " : Iterations = " << i << " : " << stop - start
                  << std::endl;
    }
}
Пример #3
0
// Return the current time as an OsTime value
void OsDateTimeWnt::getCurTime(OsTime& rTime)
{
   FILETIME theTime;
   GetSystemTimeAsFileTime(&theTime);

   // convert to __int64
   __int64 theTime_i64;
   theTime_i64 = theTime.dwHighDateTime;
   theTime_i64 <<= 32;
   theTime_i64 += theTime.dwLowDateTime;

   // convert to seconds and microseconds since Jan 01 1601 (Windows time base)
   __int64 osTimeSecs  = theTime_i64 / FILETIME_UNITS_PER_SEC;
   int osTimeUsecs = (int)((theTime_i64 % FILETIME_UNITS_PER_SEC) / FILETIME_UNITS_PER_USEC);

   // subtract to change the time base to since Jan 01 1970 (Unix/sipX time base)
   osTimeSecs -= WINDOWSTIME2UNIXTIME;

   //assert((osTimeSecs >> 32)  == 0);
   //assert((osTimeUsecs >> 32) == 0);

   OsTime curTime((long)osTimeSecs, osTimeUsecs);

   rTime = curTime;
}
Пример #4
0
void Seq::processMessages()
      {
      for (;;) {
            if (toSeq.isEmpty())
                  break;
            SeqMsg msg = toSeq.dequeue();
            switch(msg.id) {
                  case SEQ_TEMPO_CHANGE:
                        if (playTime != 0) {
                              int tick = cs->utime2utick(playTime);
                              cs->tempomap()->setRelTempo(msg.data.realVal);
                              cs->repeatList()->update();
                              playTime = cs->utick2utime(tick);
                              startTime = curTime() - playTime;
                              }
                        else
                              cs->tempomap()->setRelTempo(msg.data.realVal);
                        break;
                  case SEQ_PLAY:
                        putEvent(msg.event);
                        break;
                  case SEQ_SEEK:
                        setPos(msg.data.intVal);
                        break;
                  }
            }
      }
Пример #5
0
APIRET fsMkDir(ServerData * pServerData, struct mkdir * pmkdir)
{
   CoreResult cr;
   APIRET rc;
   VolData * pVolData;
   CryptedVolume * pVolume;
   CHAR szName[CCHMAXPATH];
   CryptedFileID idDir, idFile, idNewDir;
   CryptedFileInfo info;
   
   pmkdir->oError = 0;
   
   if (VERIFYFIXED(pmkdir->szName) ||
       verifyPathName(pmkdir->szName))
      return ERROR_INVALID_PARAMETER;
   
   GET_VOLUME(pmkdir);
   pVolume = pVolData->pVolume;
   
   logMsg(L_DBG, "FS_MKDIR, szName=%s, fsFlags=%d",
      pmkdir->szName, pmkdir->fsFlags);

   cr = findFromCurDir(pVolData, pmkdir->szName, &pmkdir->cdfsi,
       &pmkdir->cdfsd, pmkdir->iCurDirEnd, &idDir, &idFile, 0,
       szName);
   if (!idDir) return coreResultToOS2(cr);

   if (cr == CORERC_OK) return ERROR_ACCESS_DENIED;
   if (cr != CORERC_FILE_NOT_FOUND) return coreResultToOS2(cr);

   /* No.  Create a new directory. */
   memset(&info, 0, sizeof(info));
   info.flFlags = CFF_IFDIR | 0700; /* rwx for user */
   info.cRefs = 1;
   info.cbFileSize = 0;
   info.timeWrite = info.timeAccess = info.timeCreation = curTime();
   info.idParent = idDir;
   /* uid and gid are set to 0 */
   cr = coreCreateBaseFile(pVolume, &info, &idNewDir);
   if (cr) return coreResultToOS2(cr);

   /* Set the extended attributes. */
   if (pmkdir->fHasEAs) {
      rc = addEAs(pVolume, idNewDir, (PFEALIST) pServerData->pData);
      if (rc) {
         coreDeleteFile(pVolume, idNewDir);
         return rc;
      }
   }

   /* Add the directory to the parent directory. */
   cr = coreAddEntryToDir(pVolume, idDir, szName, idNewDir, 0);
   if (cr) {
      coreDeleteFile(pVolume, idNewDir);
      return coreResultToOS2(cr);
   }
   
   return NO_ERROR;
}
Пример #6
0
unsigned int NewsSite::timeSinceLastUpdate(void) const
{
    QMutexLocker locker(&m_lock);

    QDateTime curTime(MythDate::current());
    unsigned int min = m_updated.secsTo(curTime)/60;
    return min;
}
Пример #7
0
void State_LeaveCurbside::Exit(CARCportEngine* pEngine)
{
	if(m_spot)
	{
		m_spot->OnVehicleExit(getVehicle(), curTime());
	}
	
	m_pCurb->NotifyObservers();//notify waiting vehicles
}
Пример #8
0
// Return the current time as an OsTime value
void OsDateTimeLinux::getCurTime(OsTime& rTime)
{
   struct timeval theTime;
   gettimeofday( &theTime, NULL );

   OsTime curTime(theTime.tv_sec, theTime.tv_usec);

   rTime = curTime;
}
Пример #9
0
  void MessageDispatcher::DispatchDelayedMessage()
  {
    boost::posix_time::ptime curTime(boost::posix_time::microsec_clock::local_time());
    while(!msgQ_.empty() && msgQ_.top().dispatchTime_ <= curTime)
      {
	Telegram msg = msgQ_.top();
	msgQ_.pop();
	BaseGameEntity* pReceiver = EntityManager::Instance().GetEntityFromID<BaseGameEntity>(msg.receiverID_);
	Discharge(pReceiver, msg);
      }
  }
Пример #10
0
void State_TryParkingCurbside::Entry( CARCportEngine* pEngine )
{
	CurbsideStrategyStateInSim* pStragy = getVehicle()->getCurbStragy();
	if(!pStragy)
	{
		pStragy = getVehicle()->BeginCurbStrategy(m_pCurb->getName(),pEngine);
	}
	ElapsedTime maxWaitSpotTime(12*3600L);
	if(pStragy)
	{
		maxWaitSpotTime = pStragy->getMaxWaitSpotTime();
	}

	m_waitTimer.StartTimer(this, curTime()+ maxWaitSpotTime );
	Execute(pEngine);
}
Пример #11
0
void CDialogMediaControl::UpdateTimeControls()
{
	__int64 curTime(m_VLCPlayer->GetTime());
	int newPos(0);
	if (mTotalTime)
		newPos = (int)((curTime * 1024) / mTotalTime);
	CSliderCtrl *pSlider((CSliderCtrl *)GetDlgItem(IDC_SLIDER_MEDIA_POS));
	pSlider->SetPos(newPos);
	CString t;
	if (m_bShowTimeInReverse) {
		curTime = mTotalTime - curTime;
		t += _T("-");
	}
	t += GetStringTime(curTime) + mStrTotalTime;
	SetDlgItemText(IDC_STATIC_MEDIA_TIME, t);
}
Пример #12
0
void CDialogMediaControl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
    UNREFERENCED_PARAMETER(nPos);
	if (nSBCode == SB_ENDSCROLL)
		return;
	if (pScrollBar != NULL) {
		CSliderCtrl *pSlider((CSliderCtrl*)pScrollBar);
		switch (pSlider->GetDlgCtrlID()) {
		case IDC_SLIDER_MEDIA_POS:
			{
				__int64 curTime(m_VLCPlayer->GetTime());
				__int64 newTime = curTime;
				switch (nSBCode) {
				case SB_LINERIGHT:
						newTime = curTime + 5000; // 5 secs
					break;
				case SB_LINELEFT:
						newTime = curTime - 5000;
					break;
				case SB_PAGELEFT:
						newTime = curTime - 5*1000*60; // 5 mins
					break;
				case SB_PAGERIGHT:
						newTime = curTime + 5*1000*60;
					break;
				}
				if (newTime == curTime) {
					newTime = pSlider->GetPos();
					newTime = (newTime * mTotalTime) / 1024;
				}
				m_iTimeOutCount = 0;
				m_bManualPositioning = true;
				m_VLCPlayer->SetTime(newTime);
				UpdateTimeControls();
			}
			break;
		case IDC_SLIDER_MEDIA_VOLUME:
			m_VLCPlayer->SetVolume(pSlider->GetPos());
			break;
		}
	}
}
Пример #13
0
/* Set the archived bit and the last write time. */
APIRET easChanged(CryptedVolume * pVolume, CryptedFileID idFile,
   bool fHidden, struct sffsi * psffsi)
{
   CoreResult cr;
   CryptedFileInfo info;
   
   cr = coreQueryFileInfo(pVolume, idFile, &info);
   if (cr) return coreResultToOS2(cr);
   
   info.flFlags |= CFF_OS2A;
   info.timeWrite = curTime();

   if (psffsi) {
      psffsi->sfi_tstamp = (psffsi->sfi_tstamp | ST_PWRITE) &
         ~ST_SWRITE;
      coreToSffsi(fHidden, &info, psffsi);
   }

   return coreResultToOS2(coreSetFileInfo(pVolume, idFile, &info));
}
Пример #14
0
//----------------------------------------------------------------------------------------------------------------------
void myMessageOutput(QtMsgType /*type*/, const QMessageLogContext& /*context*/, const QString& msg)
{
#ifdef TEST_ONLY
    static QFile logFile("TokenTest_Log.txt");
#else
    static QFile logFile("TokenGraver_Log.txt");
#endif

    if (!logFile.isOpen()) {
        logFile.open(QIODevice::Append);
        QString newStartString("\r\n\r\n==========================================\r\n   Новый запуск   ");
        newStartString += curDateTime() + "\r\n==========================================\r\n\r\n";
        logFile.write(newStartString.toLocal8Bit());
    }

    if(!msg.isEmpty()) {
        QString logMsg = curTime() + "   " + msg + "\r\n";
        logFile.write(logMsg.toLocal8Bit());
        logFile.flush();
    }
}
Пример #15
0
int cmd_time(char *param)
{
	char s[40];
	int ec;

	noPrompt = 0;

	if((ec = leadOptions(&param, opt_date, 0)) != E_None)
		return ec;

	if(!*param) {
		char *time;

		if((time = curTime()) == 0)
			return 1;

		displayString(TEXT_MSG_CURRENT_TIME, time);
		free(time);
		param = 0;
	}

	while(1) {
		if(!param) {
			if(noPrompt) return 0;

			displayString(TEXT_MSG_ENTER_TIME);
			fgets(s, sizeof(s), stdin);
			if (cbreak)
				return 1;
			param = s;
		}
		if(my_settime(param))
			break;
		error_invalid_time();
		/* force user interaction the next time around. */
		param = 0;
	}

	return 0;
}
Пример #16
0
// Get the number of seconds since boot using /proc/uptime
// This is somewhat of a cheezy hack but there doesn't seem to be a system
// call to do it. It will work on all Linux systems with the /proc filesystem
// enabled, which is just about every one of them.
double OsDateTimeLinux::secondsSinceBoot(void)
{
   double seconds = 0;   // default to 0 if we can't open the file
   OsTime curTime(time(NULL), 0);

   if (sSecondsSinceBoot != 0)
   {
        seconds = curTime.seconds() - sSecondsFirstCall + sSecondsSinceBoot;
   }
   else
   {
        sSecondsFirstCall = curTime.seconds();
        FILE * proc;
        proc = fopen("/proc/uptime","r");
        if(proc != NULL)
        {
           fscanf(proc, "%lf", &seconds);
           fclose(proc);
        }
        sSecondsSinceBoot = seconds;
   }
   return seconds;
}
Пример #17
0
int main()
{
	int fd = open("1.txt", O_RDWR| O_CREAT, 0666);

	if (fd == -1) {
		errExit("open");
	}
	
	int flag = fcntl(fd, F_GETFL);
	
	flag |= O_APPEND;
	
	if (fcntl(fd, F_SETFL, flag) < 0) {
		errExit("fcntl");
	}

	//关闭标准输出的默认缓冲功能
	/*
	1. 缓冲区满
	2. '\n',强行刷新缓冲区
	3. fflush, 手动刷新缓冲区
	4. 关闭缓冲区
	*/
	setbuf(stdout, NULL);
	dup2(fd, STDOUT_FILENO);
	
	int n = 10;
	while (--n) {
		sleep(1);
		printf("pid:%d:%s", getpid(), curTime());
	}	
	
	close(fd);

	return 0;
}
void LandsideIntersectLinkGroupInSim::OnActive(CARCportEngine*pEngine)
{
	ElapsedTime nextTime;
	if (!m_bFirstTimeActive)
	{
		switch (m_eState)
		{
		case LS_ACTIVE:
			{
				SetState(LS_BUFFER);
				nextTime=(curTime()+(long)m_ctrlTime.bufferTime);
				break;
			}
		case LS_BUFFER:
			{
				SetState(LS_CLOSE);
				nextTime=(curTime()+(long)m_ctrlTime.closeTime);
				break;
			}
		case LS_CLOSE:
			{
				SetState(LS_ACTIVE);
				nextTime=(curTime()+(long)m_ctrlTime.activeTime);
				break;
			}
		default:
			{
				break;
			}
		}
		
	}else
	{
		if (m_nFirstCloseTime == 0)
		{
			SetState(LS_ACTIVE);
			nextTime=(curTime()+(long)m_ctrlTime.activeTime);

		}else
		{
			SetState(LS_CLOSE);
			nextTime=(curTime()+(long)m_nFirstCloseTime);
		}
		m_bFirstTimeActive=false;
	}

	//LinkStateChangeSignal *linkStateSignal=new LinkStateChangeSignal;
	//SendSignal(linkStateSignal);
	//ClearListener();
	NotifyObservers();



	WriteLog(curTime());
	if (/*m_tEndTime==0L ||*/ nextTime<m_tEndTime)
	{
		Activate(nextTime);
	}
	else
	{
		SetState(LS_ACTIVE);
	}

}
Пример #19
0
void displayPrompt(const char *pr)
{
#ifdef FEATURE_ENVVARS_IN_PROMPT
	char *buf = strdup(pr);
	char *expanded = malloc(MAX_INTERNAL_COMMAND_SIZE + sizeof(errorlevel) * 8);

	if(buf && expanded) {
		if(!expandEnvVars(buf, expanded))
			error_line_too_long();
		else
			pr = expanded;
	}
	free(buf);
#endif

  while (*pr)
  {
    if(*pr != '$') {
      outc(*pr);
    } else {
      switch (toupper(*++pr)) {
      case 'A': outc('&'); break;
      case 'B': outc('|'); break;
      case 'C': outc('('); break;
      /* case 'D': see below */
      case 'E': outc(27);  break; /* Decimal 27 */
      case 'F': outc(')');  break;
      case 'G': outc('>'); break;
      case 'H': outc(8);   break; /* Decimal 8 */
      case 'L': outc('<'); break;
      /* case 'M': outc('<'); break; remote name of current drive */
      /* case 'N': see below */
      /* case 'P': see below */
      case 'Q': outc('='); break;
      case 'S': outc(' '); break;
      /* case 'T': see below */
      /* case 'V': see below */

      case '$': outc('$'); break;
      case '_': outc('\n'); break;
      /* case '+': see below */

        case 'D':
          {	 char *p;
          	 if((p = curDateLong()) != 0) {
          	 	outs(p);
          	 	free(p);
          	 }
            break;
          }
        case 'N':
          {
            outc( ( getdisk() + 'A' ) );
            break;
          }
        case 'P':
          {
#ifdef FEATURE_LONG_FILENAMES
            char pathname[MAXDIR];
            IREGS r;
            printf("%c:\\", getdisk() + 'A');

            r.r_ax = 0x7147;
            r.r_dx = 0;
            r.r_si = FP_OFF(pathname);
            r.r_ds = FP_SEG(pathname);

            intrpt(0x21, &r);

            if(r.r_flags & 1 || r.r_ax == 0x7100) {
                r.r_ax = 0x4700;
                intrpt(0x21, &r);
            }

            if(r.r_flags & 1) break;

            outs(pathname);
#else
            char *p;

            if((p = cwd(0)) != 0) {
                outs(p);
                free(p);
            }
#endif

            break;
          }
        case 'T':
          {
            char *p;

            if((p = curTime()) != 0) {
				outs(p);
				free(p);
			}

            break;
          }
        case 'V':
          {
            /* #1776 fputs(shellname, stdout); */
            printf("%s v%s", shellname, shellver);
            break;
          }
        case '+':	/* Levels of PUSHD */
         {
#ifdef INCLUDE_CMD_PUSHD
			ctxt_info_t *info;
			int i;

			info = &CTXT_INFO_STRUCT(CTXT_TAG_DIRSTACK);
			assert(info);
			if((i = info->c_nummax) > 0) do {
				outc('+');
			} while(--i);
#endif
         }
      }
    }
    pr++;
  }
#ifdef FEATURE_ENVVARS_IN_PROMPT
	free(expanded);
#endif
}
Пример #20
0
		double elapsed() const                  // return elapsed time in seconds
		{ return  double(curTime() - _start_time) / double(1000000000); }
Пример #21
0
		void restart() { _start_time = curTime(); }
Пример #22
0
// Return the current time as an OsTime value
void OsDateTimeBase::getCurTime(OsTime& rTime)
{
   OsTime curTime(time(NULL), 0);

   rTime = curTime;
}
void GxInterface::printStats()
{
    std::unordered_map<unsigned int, std::unordered_map<uint32_t, unsigned int> >::iterator it;
    std::unordered_map<uint32_t, unsigned int>::iterator it1;
    std::unordered_map<uint32_t, unsigned int> *tmp;

    std::unordered_map<unsigned int, std::unordered_map<uint32_t, unsigned int> >::iterator reqIt;
    std::unordered_map<uint32_t, unsigned int>::iterator reqIt1;
    std::unordered_map<uint32_t, unsigned int> *reqTmp;


    it=res.begin();
    while(it != res.end())
    {
        tmp=&(it->second);
        it1=tmp->begin();
        while(it1 != tmp->end())
        {
           reqIt = req.find(it->first);
           //std::cout << "ABHINAY:: After reqIt" << std::endl;
           if (reqIt != req.end())
           {
               reqTmp = &(reqIt->second);
               reqIt1 = reqTmp->find(it1->first);
               if(reqIt1 !=  reqTmp->end())
               {
                   GxStats.latency[it->first] += (it1->second)-(reqIt1->second);
                   reqTmp->erase(reqIt1);
               } 
           }

           //if(req[it->first][it1->first] !=0)
           //{
           //    GxStats.latency[it->first] += (it1->second)-(req[it->first][it1->first]);
              //std::cout << "Diff:" << (it1->second)-(req[it->first][it1->first]) << std::endl;
           //}
           it1++;
        }

        //std::cout << "ABHINAY LATENCY is :" << GxStats.latency[it->first] << std::endl;
        it++;
    }

    char TimeBuf[300];
    time_t curT = startTime;
    struct tm * curTimeInfo;
    curTimeInfo = localtime(&curT);
    strftime(TimeBuf, 100, "%F  %T", curTimeInfo);
    std::string curTime(TimeBuf);

    for(int i=0; i< EVENT; i++)
    {
        std::string msgType;
        switch(i)
        {
            case 0:
                msgType = "INITIAL";
                break;
            case 1:
                msgType = "UPDATE";
                break;
            case 2:
                msgType = "TERMINATE";
                break;
        }
        std::cout << curTime << " Ip=" << node <<   " Ix=" << "Gx"                    << " "
                                                          << "Ty="      << msgType                 << " "
                                                          << "Kp=Att"  
                                                          << " Kpv=" << GxStats.attempts[i]     << std::endl;

        std::cout << curTime << " Ip=" << node <<   " Ix=" << "Gx"                    << " "
                                                          << "Ty="      << msgType                 << " "
                                                          << "Kp=Suc"
                                                          << " Kpv="  << GxStats.succCount[i]     << " " << std::endl;

       std::cout << curTime << " Ip=" << node <<   " Ix=" << "Gx"                    << " "
                                                          << "Ty="      << msgType                 << " "
                                                          << "Kp=Fail"
                                                          << " Kpv="      << GxStats.failCount[i]    << " " << std::endl;
       std::cout << curTime << " Ip=" << node <<   " Ix=" << "Gx"                    << " "
                                                          << "Ty="      << msgType                 << " "
                                                          << "Kp=Tout"
                                                          << " Kpv="      << GxStats.timeoutCount[i]    << " " << std::endl;


       std::cout << curTime << " Ip=" << node <<   " Ix=" << "Gx"                    << " "
                                                          << "Ty="      << msgType                 << " "
                                                          << "Kp=Laty"
                                                          << " Kpv=" <<  (float)GxStats.latency[i] << std::endl; 
    }
}
Пример #24
0
void State_NonPaxCurbsideInLotSpot::Entry( CARCportEngine* pEngine )
{
	ElapsedTime m_tExittime = curTime() + m_pOwner->GetParkingLotWaitTime(pEngine,m_pCurb->getName());
	m_sExitTimer.StartTimer(this,m_tExittime);
}
Пример #25
0
void PlayLabel::onPlayMode(PlayMode mode)
{
    m_mode = mode;

    if(m_bSelected && (m_mode == snap) && (m_pFmg != NULL))
    {
        //检查保存权限
        if(UIContext::getInstance()->right() < save)
        {
            UIUltity::warning(tr("Not have save right!"));
            return;
        }


        qDebug()<<"Playlabel "<<m_iResID<<",snap at "<<curTime()/1000<<"unit s";
//        "ffmpeg -i test.asf -y -f  image2  -ss 00:01:00 -vframes 1  test1.jpg"
        QString destPath = UIContext::getInstance()->snapFileLoc() + QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss")+".jpg";
        qDebug()<<"dest path is "<<destPath;
        QProcess p(0);
        QString command = "./ffmpeg";
        QStringList args;
        args<<"-ss"
          <<QString::number(curTime()/1000)
         <<"-i"<<m_pFmg->source()
        <<"-y"
        <<"-f"
        <<"image2"
        <<"-vframes"
        <<"1"
        <<destPath;
        p.execute(command,args);//command是要执行的命令,args是参数
        p.waitForFinished();
//        qDebug()<<"Snap finished iresid "<<m_iResID;
        UIUltity::warning(tr("Snap finished!"));
    }

    if(m_bSelected && (m_mode == rec) && (m_bRecSta == false) && (m_pFmg != NULL))
    {
        //检查录像权限
        if(UIContext::getInstance()->right() < save)
        {
            UIUltity::warning(tr("Not have save right!"));
            return;
        }

        qDebug()<<"Ready to rec";
        m_bRecSta = true;
//        m_pFmg->recStart(recFileLoc);
        m_recStartTime = 0;//初始化防止数据错误
        m_recStartTime = curTime()/1000;

        //表明录制状态
        m_pLbState->show();
        return;
    }

    if(m_bSelected && (m_mode == rec) && (m_bRecSta == true) && (m_pFmg != NULL))
    {
        qDebug()<<"End rec";
        m_bRecSta = false;
//        m_pFmg->recStop();
        m_recStopTime = 0;//防止使用之前的时间
        m_recStopTime = curTime()/1000;
        m_pLbState->hide();
        //获取存储位置
//        QString recFileLoc = UIContext::getInstance()->recFileLoc();

        //启动进程
        //先确定文件名
        QString destPath = UIContext::getInstance()->recFileLoc() +"/" + QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss")+".avi";
        qDebug()<<"dest rec path is "<<destPath;
        QProcess p(0);
        QString command = "./ffmpeg";
        QStringList args;
//        args<<"-ss"
//          <<QString::number(curTime()/1000)
        args<<"-i"<<m_pFmg->source()
        <<"-ss"<<QString::number(m_recStartTime)
        <<"-t"<<QString::number(m_recStopTime)
        <<"-acodec"
        <<"copy"
        <<"-vcodec"
        <<"copy"
        <<destPath;
        p.execute(command,args);//command是要执行的命令,args是参数
        p.waitForFinished();

        return;
    }
}
Пример #26
0
// Return the current time as an OsTime value
void OsDateTimeWnt::getCurTime(OsTime& rTime)
{
#if WINCE
    typedef union 
    {
        FILETIME  ft;
        uint64_t  int64;
    } g_FILETIME;

    uint64_t ticks ;
    uint64_t freq ;
    static bool       sbInitialized = false ;
    static g_FILETIME sOsFileTime ;
    static uint64_t sLastTicks = 0 ;
    static uint64_t sResetTime = 0 ;

    QueryPerformanceCounter((LARGE_INTEGER*) &ticks) ;
    QueryPerformanceFrequency((LARGE_INTEGER*) &freq) ;

    if (!sbInitialized || sOsFileTime.int64 > sResetTime)
    {
        sbInitialized = true ;
        GetSystemTimeAsFileTime(&sOsFileTime.ft);
        sResetTime = -1 ; // sOsFileTime.int64 + (freq - 1) ;
        sLastTicks = ticks ;
    }
    else
    {
        uint64_t delta = ticks - sLastTicks ;

        sLastTicks = ticks ;
        sOsFileTime.int64 = sOsFileTime.int64 + 
                (((uint64_t) 10000000) * (delta / freq)) + 
                (((uint64_t) 10000000) * (delta % freq)) / freq ;    
        
        SYSTEMTIME si ;
        FileTimeToSystemTime(&sOsFileTime.ft, &si) ;
    }

   OsTime curTime((long)  ((sOsFileTime.int64 - ((uint64_t) 116444736000000000)) / ((uint64_t) 10000000)), 
                  (long) ((sOsFileTime.int64 / ((uint64_t) 10)) % ((uint64_t) 1000000)));
   rTime = curTime;
#else
    typedef union 
    {
        FILETIME   ft;
        uint64_t   int64;
    } g_FILETIME;

    static bool       sbInitialized = false ;
    static g_FILETIME sOsFileTime ;
    static DWORD sLastSystemMSecs = 0 ;

    DWORD systemMSecs = timeGetTime();

    if (!sbInitialized)
    {
        sbInitialized = true ;

        // Set the precision of timings got from timeGetTime.
        timeBeginPeriod(1);
        // Resample time, since we changed the precision.
        systemMSecs = timeGetTime();

        FILETIME sft;
        GetSystemTimeAsFileTime(&sft);
        // Store in a temp and copy over to prevent data type misalignment issues.
        sOsFileTime.ft = sft;
        sLastSystemMSecs = systemMSecs ;
    }
    else
    {
        DWORD delta = systemMSecs - sLastSystemMSecs ;

        sLastSystemMSecs = systemMSecs;
        sOsFileTime.int64 = sOsFileTime.int64 + 
                            10000 * delta;  // convert delta msec to 100ns units
        
        SYSTEMTIME si ;
        FileTimeToSystemTime(&sOsFileTime.ft, &si) ;
    }

   OsTime curTime((long) ((sOsFileTime.int64 - 
                           ((uint64_t) WINDOWSTIME2UNIXTIME * 10000000)) 
                          / ((uint64_t) 10000000)), 
                  (long) ((sOsFileTime.int64 / ((uint64_t) 10)) % 
                          ((uint64_t) 1000000)));
   rTime = curTime;
#endif
}
void LandsideIntersectLinkGroupInSim::OnTerminate( CARCportEngine*pEngine ) 
{
	WriteLog(curTime());
	m_logEntry.saveEvents();
}
Пример #28
0
		timer():_start_time(curTime()){ } 
Пример #29
0
void widget::showTime(qint64 time)//时间与歌词的更新显示
{
    qint64 temp = totalTime;
//    QTime totalTime(0,(temp / 60000) % 60,(temp / 1000) % 60,time %1000);
    QTime curTime(0,(time / 60000) % 60,(time / 1000) % 60,time %1000);

    //歌词的更新显示

    if(ui->textEdit->find(curTime.toString("mm:ss.zzz").left(7)))//向后找
    {
        QString str = ui->textEdit->textCursor().block().text().replace(QRegExp("\\[\\d{2}:\\d{2}\\.\\d{2}\\]"),"");

        ui->label_lrc->setText(str);
        lrc->setText(str);
        lrc->setLrcWidth();//设置用于遮罩label的宽度为0
     //   lrc->show();

////////////////////////////////////////////////
        QTime tt = curTime;
        int b = 1;
        int c= 0;
        text->setText(ui->textEdit->document()->toPlainText());
        bool over = ui->textEdit->textCursor().block().next().text().isEmpty();
        while(!over &&!text->find(tt.addMSecs(b*100).toString("mm:ss.zzz").left(7)))
        {
            b++;
            c++;
        }
        while(over && !text->find(tt.addMSecs(b*100).toString("mm:ss.zzz").left(7),QTextDocument::FindBackward))
        {
            b++;
            c++;
            break;
        }

       lrc->timer->start(c);

    }//找不到后向前找
    else if(ui->textEdit->find(curTime.toString("mm:ss.zzz").left(7),QTextDocument::FindBackward))
    {
        QString str = ui->textEdit->textCursor().block().text().replace(QRegExp("\\[\\d{2}:\\d{2}\\.\\d{2}\\]"),"");
        ui->label_lrc->setText(str);
        lrc->setText(str);
        lrc->setLrcWidth();//设置用于遮罩label的宽度为0

       // lrc->show();

////////////////////////////////////////////////
        QTime tt = curTime;
        int b = 1;
        int c= 0;
        text->setText(ui->textEdit->document()->toPlainText());

        bool over = ui->textEdit->textCursor().block().next().text().isEmpty();
        while(!over && !text->find(tt.addMSecs(b*100).toString("mm:ss.zzz").left(7)))
        {
            b++;
            c++;
        }
        while(over && !text->find(tt.addMSecs(b*100).toString("mm:ss.zzz").left(7),QTextDocument::FindBackward))
        {
            b++;
            c++;
            break;
        }
         lrc->timer->start(c);
    }
}
Пример #30
0
void GyInterface::printStats(std::string &node)
{
    curT = startTime;
    static int RTTCount;
    /* Calculate latency */
    it=res.begin();
    while(it != res.end())
    {
        RTTCount = 0;
        tmp=&(it->second);
        it1=tmp->begin();
        while(it1 != tmp->end())
        {
           reqIt = req.find(it->first);
           if (reqIt != req.end())
           {
               reqTmp = &(reqIt->second);
               reqIt1 = reqTmp->find(it1->first);
               if(reqIt1 !=  reqTmp->end())
               {
                   GyStats.latency[(it->first)-1] = ((RTTCount * GyStats.latency[(it->first)-1]) + (it1->second)-(reqIt1->second))/(++RTTCount);
                   reqTmp->erase(reqIt1);
               } 
               else
               {
                   GyStats.timeoutCount[(it->first)-1]++;
               }
           }
           else
           {
               GyStats.timeoutCount[(it->first)-1]++;
           }
           it1++;
        }
        it++;
    }

    /* Calculate Time out requests */
    reqIt = req.begin();
    while(reqIt != req.end())
    {
        reqTmp =&(reqIt->second);
        reqIt1 = reqTmp->begin();
        while(reqIt1 != reqTmp->end())
        {
            if(reqIt1->second + DIAMETER_TIMEOUT < endTime)
            {
                GyStats.timeoutCount[(reqIt->first)-1]++;
                reqTmp->erase(reqIt1++);
            }
            else
            {
                reqIt1++;
            }
        }
        reqIt++;
    }

    /* Print Stats */
    curTimeInfo = localtime(&curT);
    strftime(TimeBuf, 100, "%F  %T", curTimeInfo);
    std::string curTime(TimeBuf);

    for(int i=INITIAL; i<=EVENT; i++)
    {
        std::string msgType;
        switch(i)
        {
            case INITIAL:
                msgType = "INITIAL";
                break;
            case UPDATE:
                msgType = "UPDATE";
                break;
            case TERMINATE:
                msgType = "TERMINATE";
                break;
            case EVENT:
                msgType = "EVENT";
                break;
        }

        std::cout << curTime << " " << node <<   " Ix=" << "Gy"                    << " "
                                                          << "Ty="      << msgType                 << " "
                                                          << "Kp=Att"  
                                                          << " Kpv=" << GyStats.attempts[i-1]     << std::endl;

        std::cout << curTime << " " << node <<   " Ix=" << "Gy"                    << " "
                                                          << "Ty="      << msgType                 << " "
                                                          << "Kp=Suc"
                                                          << " Kpv="  << GyStats.succCount[i-1]     << " " << std::endl;

       std::cout << curTime << " " << node <<   " Ix=" << "Gy"                    << " "
                                                          << "Ty="      << msgType                 << " "
                                                          << "Kp=Fail"
                                                          << " Kpv="      << GyStats.failCount[i-1]    << " " << std::endl;
       std::cout << curTime << " " << node <<   " Ix=" << "Gy"                    << " "
                                                          << "Ty="      << msgType                 << " "
                                                          << "Kp=Tout"
                                                          << " Kpv="   << GyStats.timeoutCount[i-1] << " " << std::endl;

       std::cout << curTime << " " << node <<   " Ix=" << "Gy"                    << " "
                                                          << "Ty="      << msgType                 << " "
                                                          << "Kp=Laty"
                                                          << " Kpv=" << (int) (GyStats.latency[i-1]*1000000) << std::endl; 
    }

}