From 22c80d12fcea2b647d92a0fbdf07317972dc3241 Mon Sep 17 00:00:00 2001 From: ctx0509 Date: Thu, 26 Dec 2019 21:15:17 +0800 Subject: [PATCH 1/3] this is :change --- src/common/time/test/.DurationTest.cpp.swm | Bin 0 -> 12288 bytes src/common/time/test/.DurationTest.cpp.swn | Bin 0 -> 12288 bytes src/common/time/test/.DurationTest.cpp.swo | Bin 0 -> 12288 bytes src/common/time/test/.exrc | 18 ++++++++++++ src/common/time/test/CMakeLists.txt | 32 +++++++++++++++++++++ src/common/time/test/duration.cpp | 1 + 6 files changed, 51 insertions(+) create mode 100644 src/common/time/test/.DurationTest.cpp.swm create mode 100644 src/common/time/test/.DurationTest.cpp.swn create mode 100644 src/common/time/test/.DurationTest.cpp.swo create mode 100644 src/common/time/test/.exrc create mode 100644 src/common/time/test/duration.cpp diff --git a/src/common/time/test/.DurationTest.cpp.swm b/src/common/time/test/.DurationTest.cpp.swm new file mode 100644 index 0000000000000000000000000000000000000000..47456164d19c589928e33d2c8d2cc207dd022572 GIT binary patch literal 12288 zcmeI2TW=dh6vrn#lxqON7dUk#v`$>F9U2nG5)Zr}A;CNF2tq>Q@)@`ZLAgKi$bWXdm{f(dr7u-ymEYdZ%$YO)IkQoe zvr&7rb&?KO4>25fGj`^~smJ#%>|@{Jk?SYT+dU7o`~LN32BWVZGw0kU7zLs&+#Y2^k_Vm5i*w$_pxS6|f3e1*`&A0jq#j;6_tGkEYnunDkBKiMPhrsf(`T zM|-gfSOu&CRspMkRlq7>6|f3e1*`&A0jq#j;5t;m4;cIXX2$BbB6$4&zxezA)4Le^ z1iT22fCs?>*bi<2Ki|pNPv8siId})`00kPL3@%JF_9OThd<5PD?}8n09?XLacQE!H z_y&9pz5?%qx4}6Ofx}=Le0e)#AAmQ&Yv5Jz3V0d31YQ8ogXh2wI1io$=fD=&1U@(e z9s)ny#@L%+8T^U){{emjzk*-DXW%Vx7MupBz#%XPGQFE_YrXEXfd2vSuQp+8DQ(27oW1b511T3n=3EAlxg2ftY*=Q{Tjy|~LXlwl|n!Q&`Mjyi$t z^~zNqqdL?n(=631Y!Y2@cdepqUy~>&5xOodg<-r!^I;GV}26ghk4^F+eUsZX3B~i*Yz*uxiIf?T)gyC9cN+C5!xkrqJfILiU=Rx}uc7`iyU$zU+*@ zbh1|_X)@kK-PN_GV^osKDU&n-Hsko?Vx%yZNivx?<{0-qzSQpgSLgqi8+mHXjn~Z# zoB6x)94OWF#mT7{M&;6bFI?^UrEaA%016ilY3q<4&*x^BOa!Kpi)+7 zURbJw(!{jb&+5;!b9HcZVkm9+iEtmr$+TxQ;{x)v_W3{rv?cX`ma{T;S`N*c;VBBF zDPpI3wN}CO(kL*WP(2XTZY?)gI?WC?sS;erYP)LObq6w`Bu*6<#A8H?$53(+Aq5EC zg`%aA8Ib0xHEQP;e1&G1JA?5?+e-EanjBun_Ngz>rbyzR#-O}vzE6~y6a4l{gxVBA GmHh>F##!|M literal 0 HcmV?d00001 diff --git a/src/common/time/test/.DurationTest.cpp.swn b/src/common/time/test/.DurationTest.cpp.swn new file mode 100644 index 0000000000000000000000000000000000000000..92aa1fe6a6a23ffe553f1ba72be0c1df95534f09 GIT binary patch literal 12288 zcmeI%c{Ei0AHeZj)?{KxLTZTg3>srFV+#!;YmcSSlV$J=Gh=CNagY)-QN$=i5)raR zBqltiC;MKu$nvvfPm%56_kDh+-#@>9`n%J;=e*AMeCOVC=YHPzuQ}sFvNbkC;ZLYQ z;1Gl$r|Ml7xe44*B-oN@LH~UE!vkD5#kzjU=SLS}C{!B89pmrfPo?=|)i6{y7k{!d z=CU6NL-M9jyr~$P2gMCTbGuB#===LQ(>%PX)?jmjv{^@X3S_&mBWb;cWfrp0+zy;s}Z~?dgTmUWr7k~@=Y6WOMyP$9|^zQG2YkXgK z{one13omd1xBy%LE&vyR3%~{70&oGi09*hr02hD@{DcLZT_Grp7lI=9fQJYF|Nrmz zf1>~d{RPAV+JHJh0Hgq3V16G2%>ivdE07Pw0Dgcb@Eb6TfS?&*3}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7l^|$rwztDqk>Qrc!>Qy$jZuE4otZdyAE5{ak9<9W2x<~bX zM&=|!iG+(X9*ptE@Ijbo!bHjFG-0mOVl$5P#(H~m ztKk@xWcH%*ZG?Ab_zf^pn4TLxXQsuJ;oP;AR`7R||6Od9p)q%BtlfPKjC@zR)7XEz zAeg@q0)OT3n|+;U_?S_dRqp#Hm)!S9`#`>FneaG|1Wgrb=A$0BH#P2B?iShS#ntVd zV^Q)?C6P2q>{NGaRU9x+BJ-`& zJwdJJYGWg41b9uA;5t?Nu34_#lNn`cuDBqc!d6sc$wh)7AWRpERt9E6nsaN^Dtqv` sm|@-w_8aUg+3jg^cm*#|eSvmGmUc8Y<*xaVP|=;?&rBxNu83UrCq1M*g#Z8m literal 0 HcmV?d00001 diff --git a/src/common/time/test/.exrc b/src/common/time/test/.exrc new file mode 100644 index 00000000000..e4200768bd3 --- /dev/null +++ b/src/common/time/test/.exrc @@ -0,0 +1,18 @@ +if &cp | set nocp | endif +let s:cpo_save=&cpo +set cpo&vim +vmap gx NetrwBrowseXVis +nmap gx NetrwBrowseX +vnoremap NetrwBrowseXVis :call netrw#BrowseXVis() +nnoremap NetrwBrowseX :call netrw#BrowseX(expand((exists("g:netrw_gx")? g:netrw_gx : '')),netrw#CheckIfRemote()) +let &cpo=s:cpo_save +unlet s:cpo_save +set ambiwidth=double +set backspace=indent,eol,start +set fileencodings=ucs-bom,utf-8,default,latin1 +set helplang=en +set nomodeline +set ruler +set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after +set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc +" vim: set ft=vim : diff --git a/src/common/time/test/CMakeLists.txt b/src/common/time/test/CMakeLists.txt index 1b73d25d3c8..d15c6a2a174 100644 --- a/src/common/time/test/CMakeLists.txt +++ b/src/common/time/test/CMakeLists.txt @@ -11,6 +11,37 @@ nebula_add_test( gtest ) +nebula_add_test( + NAME + test-zcs + SOURCES + test-zcs.cpp + OBJECTS + $ + $ + $ + LIBRARIES + gtest +) +nebula_add_test( + NAME + test-ctx + SOURCES + test-ctx.cpp + OBJECTS + $ + $ + $ + LIBRARIES + gtest +) + + + + + + + nebula_add_test( NAME wallclock_test @@ -26,6 +57,7 @@ nebula_add_test( nebula_add_executable( NAME duration_bm + SOURCES DurationBenchmark.cpp OBJECTS diff --git a/src/common/time/test/duration.cpp b/src/common/time/test/duration.cpp new file mode 100644 index 00000000000..9fe09e04e5d --- /dev/null +++ b/src/common/time/test/duration.cpp @@ -0,0 +1 @@ +// copyright <2018> djasioaw From 878775d9ef94dd206db62553f668ed019982e5e0 Mon Sep 17 00:00:00 2001 From: ctx0509 Date: Sat, 28 Dec 2019 01:13:46 +0800 Subject: [PATCH 2/3] this is my srcond change --- src/common/thread/test/ThreadTest.cpp | 16 ++++++++++++++-- src/common/time/test/CMakeLists.txt | 24 ------------------------ 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/common/thread/test/ThreadTest.cpp b/src/common/thread/test/ThreadTest.cpp index ae3cc65f871..02564cf477e 100644 --- a/src/common/thread/test/ThreadTest.cpp +++ b/src/common/thread/test/ThreadTest.cpp @@ -3,11 +3,11 @@ * This source code is licensed under Apache 2.0 License, * attached with Common Clause Condition 1.0, found in the LICENSES directory. */ - +#include "iostream" #include "base/Base.h" #include #include "thread/NamedThread.h" - +#include "vector" namespace nebula { namespace thread { @@ -25,6 +25,18 @@ TEST(NamedThread, ThreadName) { TEST(NamedThread, ThreadID) { ASSERT_EQ(::getpid(), nebula::thread::gettid()); } +TEST(NameThread, test) { + static int j = 0; + std::vector t; + for (int i = 0; i < 10; i++) { + std::thread mythread(j++); + t.push_back(std::move(mythread)); + } + for (int i = 0; i < 10 ; i++) { + t[i].join(); +} + ASSERT_GE(j, 10); +} } // namespace thread } // namespace nebula diff --git a/src/common/time/test/CMakeLists.txt b/src/common/time/test/CMakeLists.txt index d15c6a2a174..a2d1d7c9182 100644 --- a/src/common/time/test/CMakeLists.txt +++ b/src/common/time/test/CMakeLists.txt @@ -11,30 +11,6 @@ nebula_add_test( gtest ) -nebula_add_test( - NAME - test-zcs - SOURCES - test-zcs.cpp - OBJECTS - $ - $ - $ - LIBRARIES - gtest -) -nebula_add_test( - NAME - test-ctx - SOURCES - test-ctx.cpp - OBJECTS - $ - $ - $ - LIBRARIES - gtest -) From bedf7beeaa7107b333b22a6cc4af7fed6deb4a65 Mon Sep 17 00:00:00 2001 From: ctx0509 Date: Sun, 29 Dec 2019 02:15:32 +0800 Subject: [PATCH 3/3] third change --- src/common/time/test/.DurationTest.cpp.swl | Bin 0 -> 12288 bytes src/common/time/test/DurationTest.cpp | 29 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/common/time/test/.DurationTest.cpp.swl diff --git a/src/common/time/test/.DurationTest.cpp.swl b/src/common/time/test/.DurationTest.cpp.swl new file mode 100644 index 0000000000000000000000000000000000000000..93821fab8a570b1225177ffdcb3c7d7cd37a871f GIT binary patch literal 12288 zcmeI2PiP!f9LHZpWBgMsdKLUNRhdn;GrQX+#>qAklWkepMv_fbJh)EYyxkc(JG0EZ z*%+jF@hA!&6g&xD1of&%K~dYI;H}_Q5Ckn=6hXglW;eTADoLdtO5VU{-_E>$zxVz9 z=9h&0c1kbQFVfTIS%&KbW1An{{mK^$Q_ROLm#?X(2VNNW(+6*Qy@Li?-B4O>E8R&$ znU)uwc}kkyap;?bD0L zx6f3{C8fiunUnPBBilz>5`B2BfL1^&pcT*xXa%$aS^=%VQBy$nj*HfL1^&pcT*xXazzLth$C zIdO*H11r}@|Z@)A>`8ZSCQuo^`C65)WDrxwl?%|F#9qsvWWQv^;g5pF%a*c99-6sTII znR@7OjW8JJ`w8fo7Rwuf; zeh~PH;8Ex%%ZBT>+Xa(Hs6sUgG)Ltk8(BB}cDt->+!iZG7Frgq1VOY*b=YD4S!E2>2s^s20v5ek^J$rOB{e8~9tDco2xgM@1S1m~uUW zOu0ULTMiqU|2;5k8;1_eo5y7FfAwabBPusW$E|y9sCMoE6>2wg+x&j6$#TVT(wK|J zy^|(LiIf+H+qOz3wmqD(#7_Ak4^mgqOxKZ~>CKEi$rIT4ldPD0KQ~Q|&iaN6Pjpo~ zS^atTX?n|JJM1`#u%5$*8qa9f0^~^Pa8J0j>r0PTvodyC4b%&WyU_Jj5j&O5QW5H; zp{r7x^aM5PtF`rJt%+!wCN{sH2lbZGzp literal 0 HcmV?d00001 diff --git a/src/common/time/test/DurationTest.cpp b/src/common/time/test/DurationTest.cpp index 1c7e2dd142e..1869d7b17d4 100644 --- a/src/common/time/test/DurationTest.cpp +++ b/src/common/time/test/DurationTest.cpp @@ -7,9 +7,12 @@ #include "base/Base.h" #include #include "time/Duration.h" +#include "vector" +#include "cmath" +#include "time/WallClock.h" using nebula::time::Duration; - +using nebula::time::WallClock; TEST(Duration, elapsedInSeconds) { for (int i = 0; i < 5; i++) { Duration dur; @@ -40,7 +43,31 @@ TEST(Duration, elapsedInMilliSeconds) { dur.elapsedInMSec()) << "Inaccuracy in iteration " << i; } } +TEST(WallClock , time ) { + std::vector time1; + std::vector time2; + for (uint32_t i = 0; i < 10; i++) { + auto sec1 = WallClock::fastNowInMicroSec(); + usleep(3000); + auto sec2 = WallClock::fastNowInMicroSec(); + auto cost_time = sec2-sec1; + time1.push_back(cost_time); + } + std::cout << time1[0] << std::endl; + int64_t sum = std::accumulate(time1.begin(), time1.end(), 0); + double average = sum*1.0/10; + std::cout << "Mean Error : " << average-3000 << "ms " <