Direct Sticker Code:
1 #defineMysize 32*1024*10242 3#include <iostream>4#include <iomanip>5#include <fstream>6#include <pthread.h>7#include <stdlib.h>8#include <string.h>9#include <time.h>Ten#include <sys/time.h> One A using namespacestd; - -UnsignedintMy_buffer[mysize]; the - stringGetFileName (); - - intMainintargcChar**argv) + { - //Out current thread ID; +Cout<<getpid () <<Endl; A at structtimeval tpseed; - intN; - floatprocess; - floatrule; - -cout<<"Data Buffer is Creating ..."; in //Clean Output Buffer - fflush (stdout); to //Process Step +rule=0.01; - the for(n=0; n<mysize;n++) * { $ //Get MillionsecondsPanax NotoginsengGettimeofday (&tpseed,null); - //Get Rand the Srand (tpseed.tv_usec); +my_buffer[n]= (unsignedint)(1+(3000.0*rand ())/(rand_max+1.0)); A theprocess=n/(mysize/100.0); + - if(n% (mysize/ -)==0|| ((int) (process) <Ten) $ { $ if(process>rule) - { -Rule=rule+0.01; the //Clean outside Char -cout<<"\ r"; Wuyi /*output avaliable Char the *\033[32;5m Set fonts Properties - * \033[0m Set fonts Nomal Wu */ -cout<<"\r\033[32;5m Data Buffer is Creating \033[31;1m" About<<setprecision (2) <<process<<"%\033[32;5m ... \033[0m"; $ //Clean Output Buffer - fflush (stdout); - } - } A } +cout<<Endl; the return 0; -}
Terminal same line output progress information