コード例 #1
0
ファイル: xiami_cli.cpp プロジェクト: freedombird/xm-cli
static void dl_test(DataManager *pManager )
{
    struct timeval   start, stop, diff;
    int result;
    SongInfo *pSongs = NULL;
    
    printf("*** Get random good songs\n\n");
    gettimeofday(&start,0);
    pManager->get_rnd_list(result);
    gettimeofday(&stop,0);
    tim_subtract(&diff, &start, &stop);
    
    printf("get rnd total cost seconds=%d, %d us\n", (int)diff.tv_sec, (int)diff.tv_usec);

    printf("*** download ... \n");
    
    pSongs = pManager->get_rnd_list(result);
              
    printf("first name=%s, location=%s\n",  pSongs->name, pSongs->location);
    start.tv_sec = 0;
    start.tv_usec = 0;
    gettimeofday(&start,0);
    
    //pManager->downloadSong(pSongs->name, pSongs->location, FILE_TYPE_MP3);
    stop.tv_sec = 0;
    stop.tv_usec = 0;
    gettimeofday(&stop,0);
    tim_subtract(&diff,&start,&stop);
    printf("Downloading.....  total cost %d, %d us\n", (int)diff.tv_sec, (int)diff.tv_usec);
}
コード例 #2
0
ファイル: 0010-get-time.c プロジェクト: stillcold/src
int  main(int argc,   char **argv)
{
	struct   timeval   start,stop,diff;
	gettimeofday(&start,0);
	//做你要做的事...
	gettimeofday(&stop,0);
	tim_subtract(&diff,&start,&stop);
	printf("总计用时:%d毫秒\n",diff.tv_usec);

	//struct timeval          Now;
	//        gettimeofday(&Now, NULL); 
	//sprintf(TimeBuffer, "%.63s", Now.tv_usec+4);
	//      printf("saahdashdsa%u\n", Now.tv_usec);

	//	GetTimestamp();
	while(1){
		printf ("%s \n", GetTimestamp());
		sleep(2);
	}
}