From e5220ef9c2187d5b0d5a2ea5b898489b74161b91 Mon Sep 17 00:00:00 2001 From: Adrian Setyadi Date: Sat, 3 Feb 2018 22:58:16 +0700 Subject: [PATCH] Add 'Begin Until' to the loop battle --- .README.md.swp | Bin 0 -> 65536 bytes README.md | 18 ++++++++++-------- code/general/loop-vs-while-true.rb | 8 ++++++++ 3 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 .README.md.swp diff --git a/.README.md.swp b/.README.md.swp new file mode 100644 index 0000000000000000000000000000000000000000..5676413ac1c987d968ce67d698ee599a8ac8a2a8 GIT binary patch literal 65536 zcmeI52bf$}dG`kb!KN56#Kr-_l@?1{SyS%x5lFTqH-Tk2l8rHIp`D$*yF1qG%rZqQ zVO$_U2q`3?2Rnq45PENcm;@3CB{3~P2oNxY_CbI^DiFTkd&<4%-kDjgwEhz3`F0-t zHM2AKlzZ-b&UyQp$vtlGKChA~rg%Ldm3rCV51#Nxr@cS*l82{K_1SK--j*L$e)WR> z@%n6Y<%{_BMqOcczS&ldt#!1@TB$_Nbl zbLr~+QiZ&qlj0K_H+T;^^Qu#+X}!$)2&|95`UtF#!1@TRkHGo}tdGF@2&|95|I!iY zFP)LPiN4?6^uKQ2@0NJKr}_Jd=6xpd`#sFxrdwFZ1^y^S;e= z!1m)b^L@j-|61aA+wPS4{X2=@?`^(6Xx=X|H*D*_kNJMuy#HR}_xqaf?S21e;`jTR z-);NX{+#~8)_;ciecHUgGx7WV&G*-t_p{A_+VbY|lu>8Lus#CoBd|UK z>m#r}0_!8NJ_73_us#CoBd|UK>mx971nSt_#l(Mx$g|l0>*lJX2&8|5(E8V)jqtk& zCcs8eMOdzYTM?>n0bTGUa2V_Zmx1>nkpBsIHFzO-0k{I}2fM*8Py-u)2hIi$0%wBL z!9Bq}!1oaR-w&P-o&}x`ZU#4jW8g_(3Cw{2><2r*2Jk@e&nOnY1U?2n3f>290}Egt z+#8$@?g_q(lH!%%72ru=FDQWffWJclatnAS*b6QNj|OLhJCMb{1ilCc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E2MM#Raise: 29004.8 i/s - 20.31x slower ``` $ ruby -v code/general/loop-vs-while-true.rb -ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux] - -Calculating ------------------------------------- +ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux] +Warming up -------------------------------------- + Begin Until 1.000 i/100ms While Loop 1.000 i/100ms Kernel loop 1.000 i/100ms -------------------------------------------------- - While Loop 0.536 (± 0.0%) i/s - 3.000 in 5.593042s - Kernel loop 0.223 (± 0.0%) i/s - 2.000 in 8.982355s +Calculating ------------------------------------- + Begin Until 0.211 (± 0.0%) i/s - 2.000 in 9.469782s + While Loop 0.192 (± 0.0%) i/s - 1.000 in 5.212417s + Kernel loop 0.072 (± 0.0%) i/s - 1.000 in 13.921672s Comparison: - While Loop: 0.5 i/s - Kernel loop: 0.2 i/s - 2.41x slower + Begin Until: 0.2 i/s + While Loop: 0.2 i/s - 1.10x slower + Kernel loop: 0.1 i/s - 2.94x slower ``` #### Method Invocation diff --git a/code/general/loop-vs-while-true.rb b/code/general/loop-vs-while-true.rb index 33ae139..b5793a3 100644 --- a/code/general/loop-vs-while-true.rb +++ b/code/general/loop-vs-while-true.rb @@ -2,6 +2,13 @@ NUMBER = 100_000_000 +def fastest + index = 0 + begin + index += 1 + end until index > NUMBER +end + def fast index = 0 while true @@ -19,6 +26,7 @@ def slow end Benchmark.ips do |x| + x.report("Begin Until") { fastest } x.report("While Loop") { fast } x.report("Kernel loop") { slow } x.compare!