当前位置: 首页>>代码示例>>C++>>正文


C++ CurrentTime函数代码示例

本文整理汇总了C++中CurrentTime函数的典型用法代码示例。如果您正苦于以下问题:C++ CurrentTime函数的具体用法?C++ CurrentTime怎么用?C++ CurrentTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CurrentTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ImgLoad

// Image load callback - inserts the probes.
void ImgLoad(IMG img, void *v)
{
    // Called every time a new image is loaded

    if ( (IMG_Name(img).find("libncurses.so") != string::npos) ||
         (IMG_Name(img).find("LIBNCURSES.SO") != string::npos) ||
         (IMG_Name(img).find("LIBNCURSES.so") != string::npos) )
    {
        RTN rtngetch = RTN_FindByName(img, "getch");
        if (RTN_Valid(rtngetch) && RTN_IsSafeForProbedReplacement(rtngetch))
        {
            OutFile << CurrentTime() << "Inserting probe for getch at " << RTN_Address(rtngetch) << endl;
            OutFile.flush();
            AFUNPTR fptr = (RTN_ReplaceProbed(rtngetch, AFUNPTR(mygetch)));
            fptrgetch = (int (*)())fptr;
        }

        RTN rtnmvgetch = RTN_FindByName(img, "mvgetch");
        if (RTN_Valid(rtnmvgetch) && RTN_IsSafeForProbedReplacement(rtnmvgetch))
        {
            OutFile << CurrentTime() << "Inserting probe for mvgetch at " << RTN_Address(rtnmvgetch) << endl;
            OutFile.flush();
            AFUNPTR fptr = (RTN_ReplaceProbed(rtnmvgetch, AFUNPTR(mymvgetch)));
            fptrmvgetch = (int (*)(int, int))fptr;
        }
    }
    // finished instrumentation
}
开发者ID:EmilyBragg,项目名称:profiling-tool,代码行数:29,代码来源:tpss_lin_libncurses.cpp

示例2: main

int main(int argc, char const *argv[])
{
	char texto[200],nombre[200];
	double start, end,seconds;
	start=CurrentTime();
	char *t1,*t2,*t3;
	char *resp;
	int i; 
	system("clear");
	FILE *archivo1=NULL,*archivo2=NULL;
	resp=strstr( argv[2], ".txt" );
	if(resp==NULL){
   		error(3);
   	}
	if(argc==3&&strcmp(argv[1],"-FILE")==0){
		if((archivo1=fopen(argv[2],"r"))==NULL){
			error(1);
		}
		do{
		fscanf(archivo1,"%[^\n\r]\n|\r",texto);
		
			
			t1=strtok(texto,"\t");
			t2=strtok(NULL,"\t");
		sprintf(nombre, "./MainHaus -FILES %s %s",t1,t2);
		printf("%s-%s\n", t1,t2);
			for (i = 0; i < 31; ++i)
			{
				system(nombre);
				anilizaerror();
			}
			
			t3=strtok(t1,".");
			sprintf(nombre, "%s",t3);
			t3 = strtok(t2,".");
			sprintf(nombre, "%s_%s.out",nombre,t3);
			if((archivo2=fopen(nombre,"r"))==NULL){
			error(1);
			}
			for (i = 0; i <31; ++i)
			{
				fscanf(archivo2,"%[^\n]\n",texto);
				vector[i]=atof(strtok(texto,"\t"));
			}
			calculo();
			guardar_archivo();	
		 	printf("\n");
			

		}while(!feof(archivo1));		
		fclose(archivo1);

	}else{error(2);}

	end=CurrentTime();
	seconds=(end-start);
	printf("Segundos: %.5f\tReloj de computadora:%.10f\n",seconds,seconds/(double)CLOCKS_PER_SEC);
	return 0;
}
开发者ID:sdx360,项目名称:Poo_C,代码行数:59,代码来源:RunMainHaus.c

示例3: TEST_F

    TEST_F(TestDownloader, WaitShouldWait)
    {
      const std::string data(CHUNK_SIZE, '$');
      FakeSource src(data, CHUNK_DELAY, CHUNK_NUMBER);
      Queue q;

      Downloader dl(src, q);

      ptime t1(CurrentTime());
      dl.Start();
      dl.Wait();
      ptime t2(CurrentTime());

      ASSERT_GE(t2, t1 + millisec(CHUNK_DELAY * CHUNK_NUMBER) );
    }
开发者ID:rushad,项目名称:filetransfer,代码行数:15,代码来源:test_downloader.cpp

示例4: EnterInJournal

/*
** A "local" function of KeepState().  Enters #name# marked with #seqNo# into
** the state file (global) #journalPath#.  Used to keep a log of all writes
** performed by the memory.  Returns 1 if successful, else 0.
*/
static int
EnterInJournal(const char *name,
               double seqNo) {

  char journalRec[MAX_RECORD_SIZE];
  double now;

  memset(journalRec, 0, sizeof(journalRec));
  now = CurrentTime();

  if(sprintf(journalRec,"%10.0f %64s", seqNo, name) < 2) {
    FAIL1("EnterInJournal: write failed, errno %d\n", errno);
  }

  if(!WriteState(journalPath,
                 journalFileSize,
                 KEEP_A_LONG_TIME,
                 now,
                 journalRec,
                 strlen(journalRec))) {
    FAIL("EnterInJournal: write state failed\n");
  }

  return(1);

}
开发者ID:LogisticalComputingAndInternetworking,项目名称:LoRS,代码行数:31,代码来源:nws_memory.c

示例5: DoSearch

/*
** A "local" function of ProcessRequest().  Searches through the registration
** file for unexpired objects that match #filter#.  Returns a malloc'ed string
** of the matching objects.
*/
static char *
DoSearch(const char *filter) {

  unsigned long expiration;
  char expirationImage[15 + 1];
  unsigned long now;
  const char *object;
  const char *registration;
  char *returnValue;

  now = (unsigned long)CurrentTime();
  returnValue = strdup("");

  for(rewind(registrationFile); (registration = ReadRegistration()) != NULL;) {
    (void)GETWORD(expirationImage, registration, &object);
    expiration = atol(expirationImage);
    if((expiration == ETERNAL) || (expiration > now)) {
      object++; /* Skip space after expiration. */
      if(MatchFilter(object, filter)) {
        returnValue =
          REALLOC(returnValue, strlen(returnValue) + strlen(object) + 1);
        strcat(returnValue, object);
      }
    }
  }

  return returnValue;

}
开发者ID:LogisticalComputingAndInternetworking,项目名称:LoRS,代码行数:34,代码来源:nws_nameserver.c

示例6: DoClean

/*
** A "local" function of ProcessRequest().  Implements the MEMORY_CLEAN service
** by deleting all files in the memory directory that have not been accessed
** within the past #idle# seconds.  Returns 1 if successful, else 0.
*/
static int
DoClean(unsigned long idle) {

  struct dirent *entry;
  DIR *directory;
  time_t expiration;
  char filePath[255 + 1];
  struct stat fileStat;
  char *namePlace;

  directory = opendir(memoryDir);
  if(directory == NULL) {
    FAIL1("DoClean: unable to open directory %s\n", memoryDir);
  }

  expiration = (time_t)CurrentTime() - (time_t)idle;
  SAFESTRCPY(filePath, memoryDir);
  namePlace = filePath + strlen(filePath);

  while((entry = readdir(directory)) != NULL) {
    strcpy(namePlace, entry->d_name);
    if(stat(filePath, &fileStat) != 0) {
      WARN1("DoClean: unable to state file %s\n", filePath);
    }
    else if(fileStat.st_mtime < expiration) {
      LOG2("DoClean: deleting %s, last modified %d\n",
           filePath, fileStat.st_mtime);
      (void)unlink(filePath);
    }
  }

  (void)closedir(directory);
  return(1);

}
开发者ID:LogisticalComputingAndInternetworking,项目名称:LoRS,代码行数:40,代码来源:nws_memory.c

示例7: CompressRegistrations

/*
** A "local" function of main().  Deletes from the registration file all
** objects that have an expiration time which has already passed.
*/
static void
CompressRegistrations(void) {

  size_t bytesCompressed = 0;
  unsigned long expiration;
  char expirationImage[15 + 1];
  const char *ignored;
  unsigned long now;
  size_t recordLen;
  const char *registration;

  now = (unsigned long)CurrentTime();

  for(rewind(registrationFile); (registration = ReadRegistration()) != NULL;) {
    (void)GETWORD(expirationImage, registration, &ignored);
    expiration = atol(expirationImage);
    recordLen = strlen(registration) + 1;
    if((expiration != ETERNAL) && (expiration <= now)) {
      bytesCompressed += recordLen;
    }
    else if(bytesCompressed > 0) {
      /* Move this record forward to the end of the still-current objects. */
      fseek(registrationFile, -(recordLen + bytesCompressed), SEEK_CUR);
      fprintf(registrationFile, "%s\n", registration);
      fseek(registrationFile, bytesCompressed, SEEK_CUR);
    }
  }

  /* Truncate any records that we've moved. */
  if(bytesCompressed > 0) {
    fseek(registrationFile, -bytesCompressed, SEEK_CUR);
    ftruncate(fileno(registrationFile), ftell(registrationFile));
  }

}
开发者ID:LogisticalComputingAndInternetworking,项目名称:LoRS,代码行数:39,代码来源:nws_nameserver.c

示例8: memset

//Construct Response Header 
char *constructHeader(char* FilePath)
{
   FILE *fp;
    fp=fopen(FilePath+1,"r");
   if(fp==NULL)
     return NULL;
   else
   {
    char *header =malloc(sizeof(char)*BUF_SIZE);
    memset(header,0,sizeof(char)*BUF_SIZE);
    strcpy(header,"HTTP/1.1 200 OK\nConnection: close\nDate: ");
    char *time = CurrentTime();
    strcat(header,time); 
    strcat(header,"Last-Modified: ");
    char *modtime = LastModified(FilePath);
    strcat(header,modtime); 
    strcat(header,"Content-Length: ");
    int leng = Length(FilePath);
    char len[32];
    sprintf(len,"%d",leng);
    strcat(header,len);  
    strcat(header,"\nContent-Type: ");
    char *type = FileType(FilePath);
    strcat(header,type);  
    strcat(header,"\r\n\r\n");    
    return header;
    free(header);
    }
   fclose(fp);   
}
开发者ID:Haosheng,项目名称:Concurrent-Web-Server-using-BSD-sockets,代码行数:31,代码来源:serverSelect.c

示例9: ResetTimer

//This function reset timer according to first PCB in timer queue
int ResetTimer(){
	MEMORY_MAPPED_IO mmio;    //for hardware interface
	int SleepTime;

	//when timer queue is not empty
	if (timerQueue->Element_Number > 0){
		//calculate sleep time
		SleepTime = timerQueue->First_Element->PCB->WakeUpTime - CurrentTime();
		//set timer only if it's positive
		if (SleepTime > 0){
			mmio.Mode = Z502Start;
			mmio.Field1 = SleepTime;   // You pick the time units
			mmio.Field2 = mmio.Field3 = 0;
			MEM_WRITE(Z502Timer, &mmio);
			//if success, return 1
			return 1;
		}
		else{
			//if sleep time is negative, return 0
			return 0;
		}
	}
	else{
		//if timer queue empty, return -1
		return -1;
	}
}
开发者ID:tyang1991,项目名称:Operating-System,代码行数:28,代码来源:Control.c

示例10: peer_id

	PeerInterface::PeerInterface(const PeerID & peer_id, Uint32 num_chunks) : peer_id(peer_id),pieces(num_chunks)
	{
		stats.interested = false;
		stats.am_interested = false;
		stats.choked = true;
		stats.interested = false;
		stats.am_interested = false;
		stats.download_rate = 0;
		stats.upload_rate = 0;
		stats.perc_of_file = 0;
		stats.snubbed = false;
		stats.dht_support = false;
		stats.fast_extensions = false;
		stats.extension_protocol = false;
		stats.bytes_downloaded = stats.bytes_uploaded = 0;
		stats.aca_score = 0.0;
		stats.has_upload_slot = false;
		stats.num_up_requests = stats.num_down_requests = 0;
		stats.encrypted = false;
		stats.local = false;
		stats.max_request_queue = 0;
		stats.time_choked = CurrentTime();
		stats.time_unchoked = 0;
		stats.partial_seed = false;
		killed = false;
		paused = false;
	}
开发者ID:KDE,项目名称:libktorrent,代码行数:27,代码来源:peerinterface.cpp

示例11: CurrentTime

// returns false if there were no timers
bool TIMEOUT::CheckTimers(LARGE_INTEGER& ret)
{
	LARGE_INTEGER now = CurrentTime();
	TIMEOUT *t;

	if (!g_Timeouts.Head())
		return false;

	ret.QuadPart = 0LL;
	while (1)
	{
		t = g_Timeouts.Head();
		if (!t)
			return true;

		if (t->Expires.QuadPart > now.QuadPart)
			break;

		t->DoTimeout();
	}

	// calculate the timeout
	ret.QuadPart = t->Expires.QuadPart - now.QuadPart;

	return true;
}
开发者ID:bragin,项目名称:ring3k,代码行数:27,代码来源:timer.cpp

示例12: ReadBlocks

status_t
TAPEReader::GetNextChunk(void* oCookie, const void** oChunkBuffer,
	size_t* oChunkSize, media_header* oMediaHeader)
{
	int64		aOutSize;

	// check whether song is finished or not
	if (mReadPosTotal - mReadPos + mPlayPos >= mDataSize)
		return B_ERROR;

	// reading data
	if (mPlayPos >= mReadPos )
		ReadBlocks();

	// passing data
	if (mReadPos-mPlayPos >= BUFFER_SIZE)
		aOutSize = BUFFER_SIZE;
	else
		aOutSize = mReadPos-mPlayPos;

	*oChunkBuffer = &mDecodedData[mPlayPos];
	mPlayPos += aOutSize;

	// passing info
	*oChunkSize = aOutSize;
	oMediaHeader->start_time = CurrentTime();
	oMediaHeader->file_pos = mPlayPos;
	return B_OK;
}
开发者ID:looncraz,项目名称:haiku,代码行数:29,代码来源:APEReader.cpp

示例13: CurrentTime

void Logger::fillFileBuffer(std::string &outputBuffer, const std::string &tag, const std::string &msg,
	const char *funcName, const char *sourceFile, unsigned int lineNum)
{
	// Old format
	if (!isHTML)
	{
		if (!tag.empty())
			outputBuffer = "[" + tag + "] ";
		else outputBuffer = "[NOTAG] ";

		if (sourceFile != NULL)
		{
			outputBuffer += sourceFile;
			outputBuffer += " ";
		}

		if (funcName != NULL && lineNum != 0)
		{
			outputBuffer += funcName;
			outputBuffer += ":";
			// Convert int to char
			outputBuffer += std::to_string(lineNum);
		}

		outputBuffer += ": ";
		outputBuffer += msg;
		outputBuffer += "\n";
	}
	else
	{
		outputBuffer = "<tr>";
		if (!tag.empty())
			outputBuffer += "<td>" + tag + "</td>";
		else outputBuffer = "<td>NOTAG</td>";

		outputBuffer += "<td>" + CurrentTime() + "</td>";

		if (sourceFile != NULL)
		{
			outputBuffer += "<td>";
			outputBuffer += sourceFile;
			outputBuffer += "</td>";
		}

		if (funcName != NULL && lineNum != 0)
		{
			outputBuffer += "<td>";
			outputBuffer += funcName;
			outputBuffer += ":";
			// Convert int to char
			outputBuffer += std::to_string(lineNum);
			outputBuffer += "</td>";
		}

		outputBuffer += "<td>";
		outputBuffer += msg;
		outputBuffer += "</td></tr>";
	}
}
开发者ID:0ldm0s,项目名称:IntWars,代码行数:59,代码来源:Logger.cpp

示例14: CurrentTime

//-------------------------------------------------------------------
// TempFileName::GenerateRandomName
//-------------------------------------------------------------------
String TempFileName::GenerateRandomName()
{
  if( !s_lLastNumber )
    // Initialize random sequence
    s_lLastNumber = CurrentTime().long_unix();

  return String::str_format("temp%lx", s_lLastNumber++);
}
开发者ID:MaxIV-KitsControls,项目名称:EPU61,代码行数:11,代码来源:FileName.cpp

示例15: myCryptHashData

BOOL WINAPI myCryptHashData(HCRYPTHASH hHash, BYTE *pbData, DWORD dwDataLen, DWORD dwFlags) {
	FILE *fd = fopen("C:\\CryptoBlock32.txt", "a");
	std::string mytime = CurrentTime();
	fprintf(fd, "%s myCryptHashData(%x,%p,%x,%x)\n", mytime.c_str(), hHash, pbData, dwDataLen, dwFlags);

	fclose(fd);
	return Real_CryptHashData(hHash, pbData, dwDataLen, dwFlags);
}
开发者ID:raghavendravp,项目名称:Charlie-2,代码行数:8,代码来源:hookcrypt.cpp


注:本文中的CurrentTime函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。