From 34fa6155d5a9886d655254fc85a0a86ecb31e9c0 Mon Sep 17 00:00:00 2001 From: JamesonHuang Date: Wed, 29 Jul 2015 20:31:49 +0800 Subject: [PATCH] add test code about c & sh --- 1_3.test_code/c_test/atoi/atoi | Bin 0 -> 8832 bytes 1_3.test_code/c_test/atoi/atoi.c | 34 +++++++ .../c_test/testMainArgv/testMainArgv | Bin 0 -> 8616 bytes .../c_test/testMainArgv/testMainArgv.c | 19 ++++ 1_3.test_code/c_test/testTimeStamp/test | Bin 0 -> 8728 bytes 1_3.test_code/c_test/testTimeStamp/test.cpp | 46 +++++++++ .../c_test/testTimeStamp/testTimeStamp | Bin 0 -> 8680 bytes .../c_test/testTimeStamp/testTimeStamp.c | 95 ++++++++++++++++++ 1_3.test_code/sh_test/testMemory.sh | 9 ++ 9 files changed, 203 insertions(+) create mode 100755 1_3.test_code/c_test/atoi/atoi create mode 100644 1_3.test_code/c_test/atoi/atoi.c create mode 100755 1_3.test_code/c_test/testMainArgv/testMainArgv create mode 100644 1_3.test_code/c_test/testMainArgv/testMainArgv.c create mode 100755 1_3.test_code/c_test/testTimeStamp/test create mode 100644 1_3.test_code/c_test/testTimeStamp/test.cpp create mode 100755 1_3.test_code/c_test/testTimeStamp/testTimeStamp create mode 100644 1_3.test_code/c_test/testTimeStamp/testTimeStamp.c create mode 100755 1_3.test_code/sh_test/testMemory.sh diff --git a/1_3.test_code/c_test/atoi/atoi b/1_3.test_code/c_test/atoi/atoi new file mode 100755 index 0000000000000000000000000000000000000000..f0dc018f9fb2237f975cc7d1b0c6bc090cb95477 GIT binary patch literal 8832 zcmeHMZ){uD6~DIQByFjalmdY=Y7M%jXfa7!N;=qhPMY?mOWUkXfx*%jCw3AS$Ik5M zE=5CRN`YBjq0*+Q?92LTs`g>)HfhV3(R4*rOiT*XCc)OB3IR&WAB7cAhDNjBx$hkN z`Nf&ohkcoP<@e4#zkANP=bm@}`-#r(9e$rrN%E_&D&i)BhK8Isvgdokl?rQs z^vKuxkY+*qb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ZE&V*KF(NjSiyzlTfP&sYvd~s2v*swX+T#ksQuXiR_q)q%(FR z5^e8lwqwK04X5*wfqW7N)nr^nh#QIJMpPtzBn^8GwX;si;Y2o<%%sa03uW0vDn<&N z8%xGoz!4wCxRW1wMciS)1QjQW8Kf@2!XjlwA?8QYS0oK{Zto zuP%;HC3c+#JY!=q?PX>y^xd<@j1f$0=_Ls2gw}RSCbb zcwTqw1Qcd3p6AN(M%7ahzghKH#AVhlS)uu>N`0_cLYy3}4?gUoz5dg>;79z=c)knW z!w^32!J~|O*P{ou{gR(Dj}B>kX*`d!9a-PN>hv7mz6#%E3V5YY63};j*@~^t)eSd2hd}hNHd;-~CqLYY=C;WuPSM-j{%fHB$aE zHNLc;><3;a9tOTfEgeVw8ZWm^+;^72Pb`D~LgTB|VcwtUMHF^^2b}!z_UAtU z4^u^+^cwI6f1`TH)6d@~T$RRq73+Njywbg24FX8&jF|SccTiM%V*{y#qK$xa+pDaE-W9Np z=f2o5gEKfH~uq2cxD*kK5}t1Z8AMp-Unjl|M%cxQF(g&*-` z+REn=aeb5Rv0G{?1qW?NBVtZ)2J%Cw340voo%`)whpm0wK{`^gTn@d1zDc=RzB(@l zEeny8FGeAiUR4%Q{gEnk&rPu%M>*}rlK$V)-VTJ+9~yW+kcex+u5M(Z`)Y^G~=XCdn&K~ zGr%aWsu@I+D4$w)kf{?Ma8!TJ-d-!6e+JEA9M zf9%nh{r3yhsgdLy?Ql-4B~SDe9`awRk$w6M>wD|-wx8nb*1uF^06`pC|31x?US9p* zpvbK+`~EP0sI^q+O7i^#nnosshr3(xd?5eFdgZB~8yk&GgF<-Po?kRcbP z{xF{_!kPug File Name: atoi.c + > Description: + > Conclusion: + > Author: rh_Jameson + > Created Time: 2015年07月15日 星期三 22时26分47秒 + ************************************************************************/ +#include +#include +#include + + +char buf[50]; + +char * timestamp() +{ + time_t time_stp; + time ( &time_stp ); + printf("%ld\n", time_stp); + sprintf(buf, "%d", time_stp); + return buf; +} + + +int main(int argc, char *argv[]) +{ + //printf("timestamp: %s\n", timestamp()); + char *str = timestamp(); + int test = atoi(str); + time_t tt = atoi(str); + + printf("%d\n", test); + printf("%d\n", tt); +} diff --git a/1_3.test_code/c_test/testMainArgv/testMainArgv b/1_3.test_code/c_test/testMainArgv/testMainArgv new file mode 100755 index 0000000000000000000000000000000000000000..ed1971fb2456dc2de9ef7d4912cc00844e80063e GIT binary patch literal 8616 zcmeHMeQaA-6+gD~)i1{>9k?y57Hg$!C|;6gCGFVyoUguAX&c(418wPx6FZ3^wj=vF zB-JJg*(zD3TLeYw`d5Vd$21KwA+bdW(Ug={s36imDpi7^f!dL-Y|7Xu6?8S{+;@)s z{NhX#5`WQSy?5^UosawR?tAy#>uAo!q`qbZn91{+nsDL&cm+25;bl5q^6L~Y)H7tI0E@7VP6u8!o~<)6hb|L#is z$G_kGUiD;E|&HLXWWx}3BIfl~O!74R=19>8lEVZR5dn>%1E6-$^yke*DN(Kr|e zX^gZPPMJnL97`ZF98V?~F6X5st6N5^;$X_U6!}C)am9;jU#$Bl1hTG%oQ-7<{Pn2I>69D~%IkSB65PIlS z7pmsP)8e_ueuXBvZ5Qxfy+y+k$s?q^`F0Lz+s{d+Cf;07@=r;orrn%V@~b3MlWx9_ za>IL_*(*o%>|gY$>r34|otNgOD>TqAoewB>>3F#Yi*KUgM?=+H+5lz`UHJuCK2ScCQ4Vm&= zKR~~Hun))~x6pUZr_)tJc zC%K5zVxq{Nq%7whLAC>3cLUFMJORB2h%om16jc@3w(BV)v7wQf5be-Jx zr^)~h*2y~JhdQ&jJF{0C{?PR>wY^F||FLKB*B@g`UwF@aP{y|_`)*hEb{j^>ZTO=; zHSf}Q-pag76Y1%`&@-XF(2A`tCbFeEs_Dt9XARur0Eh zkp>jfA~f2C?Uv9T>OIts@5g4(H9?FI(iUX6F%4GwUt%Vu1X)_v?hHG{U0F%rqcERTTxH;*Y4(W-DKKN?a^!Ov&w|07+Mm)tF0|BIe> zZ{TEEi?{ZB<+`{2c!ln5o~k_H)yBNdA#Z)iTifCdpdH$`c&k*uUPJfO7{~s7ppf_J z{s`P3f%_wHe+2%2N1z|`Df`bQ-Cf85I@Nj~k?h~@Wu^&U&6e3)p~tr3IO>JHGsobr7lzs2AI=ECwhFs6S* zvKCrWVg0B4n&@*DgITU$@EMk+-BKSW@rp#o zD$zRN!d->4{q+5JB-3ST}Bq%0Nx&&q54vib0L6=(T#|2Nw^+waAO zx=K9vt%$Fu`OouK*0(0a11eVWty|&C=gHHE`*0O?&XWPe*TeGnh)#M+owGf=0zSP0 z{u9KhUgy011>&XJe;M%_w;wdee7;6F6yEDH?)G01r}3dDkvxqtg=}7>xog%+?Vu7*VxKTRzsQucp~gb*%&8 zVr<#5uv2ZXp!mQT2RWTIM#6~*w!`Q=fX#@+5=JH+#ZDKxK%K_6B@pCJ8<<26fU_TaUPa^)3SIsgo!G;ycsqf7Z|Ssm%D+Y5YMa00 z;eHB=A{~hWS zlGs~PK^FWLD(wFGeF9g|ERM{@PdGgvyT9aR&FnAjlrZ8a^1rY^nDk%r9GxAV_B File Name: testMainArgv.c + > Description: + > Conclusion: + > Author: rh_Jameson + > Created Time: 2015年07月14日 星期二 12时59分50秒 + ************************************************************************/ + +#include +#include +int main(int argc,char *argv[]) +{ + printf("参数个数= %d\n", argc); + printf("参数1= %s\n", argv[1]); + printf("参数2= %s\n", argv[2]); + printf("参数3= %s\n", argv[3]); + return 0; +} + diff --git a/1_3.test_code/c_test/testTimeStamp/test b/1_3.test_code/c_test/testTimeStamp/test new file mode 100755 index 0000000000000000000000000000000000000000..0ca7b1982628ab7f623837f63c1a0ac4e0ea0326 GIT binary patch literal 8728 zcmeHMZ){W76~DIg4+4(EfTgg4)siZ7&1(`u7FreT{Nn`~NP|surZw7!5(ENGn!5DECZukYHLX)p+KH|dWoX4a=e~37 z=a-iWP1`rF_1?MXch5QZ-1F{#zuX@haJyWBlUwW+$PHBoBxJsYxUfaCgmsHGA|SSj zt)d2yYIp*&1gV*0x=f~-){&eCXcau&Z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_V~RH7{(R-!^Hd4InuZ9s0cQN;hl%as?Yn`0tw1H+LAP`Ic8$|Lz_OYJ44i9HwVV1 zN38gfO`rG2VeHh9_mP{7WN$zAPpdxv|H=Q0c9I?w zyZ*0i`n)fnr}}TRB2oT+49`Ob`zUp{(ms*@C$-Dl`QL(WgGHbB`AyXE?ecd12Iyk@ zxqjYH`|nf#PoRr^kM;T7!2e_O|JB?-xqj|Hf3wxk{|hc-qad-o$(4D=Z$g39|I#^x zDo|OGDC;rB?_<^HeVj`A>?fOHJ?8I11~G0w?~9%%MY}xKWleanL9ERRLZ0;x*l^Zo z+6d)bw^j7VTt5p^p^cSw^VqTKUqr)@#^}R64Ea`gxIH|7;rMi_-$w#7HskjC{|#4s Bq80!E literal 0 HcmV?d00001 diff --git a/1_3.test_code/c_test/testTimeStamp/test.cpp b/1_3.test_code/c_test/testTimeStamp/test.cpp new file mode 100644 index 0000000..91c6331 --- /dev/null +++ b/1_3.test_code/c_test/testTimeStamp/test.cpp @@ -0,0 +1,46 @@ +/************************************************************************* + > File Name: test.cpp + > Description: + > Conclusion: + > Author: rh_Jameson + > Created Time: 2015年07月15日 星期三 15时52分24秒 + ************************************************************************/ +/* 微秒 */ + +#include +#include +#include +int main() +{ + struct timeval t_val; + gettimeofday(&t_val, NULL); + printf("start, now, sec=%d m_sec=%d \n", t_val.tv_sec, t_val.tv_usec); + long sec = t_val.tv_sec; + time_t t_sec = (time_t)sec; + printf("date:%s", ctime(&t_sec)); + return 0; +} + + +/*纳秒 +#include +#include + +int main() +{ + struct timespec time1 = {0, 0}; + clock_gettime(CLOCK_REALTIME, &time1); + printf("CLOCK_REALTIME: %ld, %ld\n", time1.tv_sec, time1.tv_nsec); + time_t tmp = time1.tv_sec * 1000000000 + time1.tv_nsec; + printf("CLOCK_REALTIME: %ld\n", tmp); + + clock_gettime(CLOCK_MONOTONIC, &time1); + printf("CLOCK_MONOTONIC: %ld, %ld\n", time1.tv_sec, time1.tv_nsec); + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1); + printf("CLOCK_PROCESS_CPUTIME_ID: %ld, %ld\n", time1.tv_sec, time1.tv_nsec); + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &time1); + printf("CLOCK_THREAD_CPUTIME_ID: %ld, %ld\n", time1.tv_sec, time1.tv_nsec); + + printf("%ld\n", time(NULL)); +} +*/ diff --git a/1_3.test_code/c_test/testTimeStamp/testTimeStamp b/1_3.test_code/c_test/testTimeStamp/testTimeStamp new file mode 100755 index 0000000000000000000000000000000000000000..3362ca8e2020648122dfe3c92c90cf331ed5a425 GIT binary patch literal 8680 zcmeHMUu;w775{AKAO9SO(Jh6xSS^_XQcMy84OA=FP6F2~KnPCRR>H-xZxRpx$?R(y zcv-3xB#Wj)+8&_V1C{oWNqa!6)a9v|W&$SdA+0o2X`9B-S|w$zQo&HPwRq=z_Z<8B z#+lHh?TIh)J>U7AKi~Pz{r=wkxTklY)8PMN#s#zrew|Je=yWQw!t@yv7EC!pq}X1mC{#7+{XLU^Sd z?J!o4Te3h;$_i73;!ugQ9kOWGOm@v=$8?SYW6J%*zTq!K{z6U#IOG*1qFX*o6m_xm zePTqhK2|GPpo*+8?J!}%l!7<;<03Q zyk)#|SIe#rUnb>im;FZnsJs8rfNY8L=midA-T*%w11LZK=ALzfuMhs>-Mb%M+5F3G z&usnc{YPlaKd3%-Sp%BuD`?|5s)WC=0^Yg;9st}6zhwpT5y9^75}KAV!jV&2Wb~9a z9FE1sSUQ$8hQ)|(7_o$&8jgm~fD#&@X4=pa;aC!okwhv(u&Gf4VN^(SSG=Pkja(PQE`>@e?KycV2> zvJ^F2aE=89trnceCgPnI+&X{N$-mdB7pfC$yh1&fH>&4f1!Z;ew{^2$YZDrdC4C@9z$HXD)|8N7}~-W;M+bA<~}^3 z=I*MKe_QMe1#jkCVaBO9ujgx!+g1AJ&3$ru z(+qf%;WrFkLqXvVD8GTA7@WnZhkeYykMaTa^)IA@>yKREK+P?x*XQ@DjvMNSkBp~^ z-qx_U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uOB1aSP-5-r_>h!uyRf_ECW=kwSM0T)TJ z1}OI3ejj-SFue1yJ)hfDx(JPc%v$XEI{`wxv#>p%@2-+P-v>E<)?<1K?C}o7eBPzV z=JI6UDmn9iZPxe+7H6S?Ic0l3FD{aOBPnwG_Wr*?_5sr4b7dX9sBw!u_Qh`h7GM|` z<`)Z}KPSlEeo`XXREB2`epY)vr(Pk&lSNIlg8#e0!t`fQx7zbQ!xv-RPppOQ7<(Hk zR(n48cHp3f!uM5^Gjq*#q*vgF_S_7gj}@}t4l--8_kS9MR(t+`<`~&`SdF1>w|~!O z&*$xFvVUN+=l92O9xC`RTpBLLb2AoW&h|_j zK+bJjRo~|JS&@V`R<_M^$7(-~j-jaZ;+} File Name: testTimeStamp.c + > Description: + > Conclusion: + > Author: rh_Jameson + > Created Time: 2015年07月14日 星期二 13时05分04秒 + ************************************************************************/ +/* +#include +#include +int main() +{ + time_t rawtime; + time ( &rawtime ); + printf("%ld\n", &rawtime); + printf ( "The current local time is: %s", ctime (&rawtime) ); +} +*/ +/* ctime example +#include +#include + + +int main () +{ + time_t time_stp; + time ( &time_stp ); + printf("%ld\n", time_stp); + printf ( "The current local time is: %s", ctime (&time_stp) ); + + return 0; +} +*/ + +/* 用time()取得时间(秒数),利用localtime() + +转换成struct tm 再利用mktine()将struct tm转换成原来的秒数*/ + +#include + +#include +/* +int main() + +{ + + time_t timep; + + struct tm *p; + + time(&timep); + + //printf("time() : %d \n",timep); + + p=localtime(&timep); + + timep = mktime(p); + + printf("time()->localtime()->mktime():%d\n",timep); + +} +*/ + +#include +#include + +#include + + + +int main() +{ + /* + struct timeval tv; + struct timezone tz; + gettimeofday(&tv,&tz); + + printf("tv_sec:%ld\n",tv.tv_sec); + printf("tv_usec:%ld\n",tv.tv_usec); + printf("tz_minuteswest:%d\n",tz.tz_minuteswest); + printf("tz_dsttime:%d\n",tz.tz_dsttime); + */ + struct timeval tpstart,tpend; + long iTimeInterval; + gettimeofday(&tpstart,NULL); + /* to do what you want*/ + gettimeofday(&tpend,NULL); + iTimeInterval=1000000 * (tpend.tv_sec - tpstart.tv_sec); + iTimeInterval += tpend.tv_usec - tpstart.tv_usec; + /*iTimeInterval 就是微妙级的时间跨度*/ + printf("tpstart:%ld\n", tpstart.tv_usec); + printf("tpend:%ld\n", tpend.tv_usec); + printf("iTimeInterval:%ld\n", tpend); + +} diff --git a/1_3.test_code/sh_test/testMemory.sh b/1_3.test_code/sh_test/testMemory.sh new file mode 100755 index 0000000..bc2af87 --- /dev/null +++ b/1_3.test_code/sh_test/testMemory.sh @@ -0,0 +1,9 @@ +#!/bin/sh +var=1 +obj=40 +while ((${var} < ${obj})); do + ./testMemory.sh #call self + var=$((var+1)) + echo "unlimited recursive call..." +done +