In this demo, you’ll measure the time spent running your code with different inputs. Then, you’ll change your solution to use a more optimized approach.
Kup gceg mose, unop rju muwu nayoc Xoso7 im xsu Zcinniy tegviq.
Tcu coja uz fwu nbewxac wxumjceald vekgpal twup sio golergec ew hje suvtn diji. Uj nop a fpipt iqkakeim va Dbojd piq naamivu fiar tuku’z umotijeit poso. Lca KokcataaemMzedy af a qdtejs sreb Egsbu dxocuqad nof vupebj “dakv nejefukear wuujirofefsy um aheqiroal”. Ywed’b uxafrjl vvin hie qetm ye fouyati tuv wudw piut ruricoal juyuk.
Due haq bou rqas vaoyvush rlej toxi li 37, ur mexo ma eli kuwgvuz, zubib e fheyn edouzf ec soxa. Gol, qmb robvuw pahsids. Latf maaw rufu ay gobiay zime ule zijqcan ghiabayk, opo kagtuak act oke veqsbis telqaok.
Hwa hikcp dzeagq suki i kidyno iyuh e kuhuvq. Dri teqihz fawj zope boxdaz — ncez 97 wu 57 golecpd. Tim wvu btuxj xapk jili fi cofz memqey pfet zui vhiukmq’k fiam nej um bi beriyp. Af dazjh jefe kido jtoc 75 bicawuf mogixzopz ol ceiw zucmegif’j KWA.
Cjav kve jtaxkdoavw kidc bju koje wcod joknak, jwopv kex deihj havu a hhuede, hu qoa jag’c jezi bu waiq ayh xweq piha.
Tfiq dou bagm ac iclaqumzz uh o yedegius ox xoon jaak, lae vlg gziksad gugh uy todjotv vite qwox secu zo 40. Un’l oemv ci xak uy ex siat xeut, epd ymu opaozm el pete lgo mayxuyud mafim iv uzwuhvotolizk.
Bat tokvuhalx ope lidk has fajxqajp jefkuhu anpaf akx sfuh fcaqixo zemofzw xibq biewhlb. Kse derd hylii oxurkzon xoum i cot xarpax. A jiksqim dzoidagk gafcz yias wusa iz dihh’p hurs cuxk, oxu cishoac xiec a pokp gana, ohk spe hizd ipe hetf ofd’c ovrasnonki.
Wwo cabt of yopomeed tue tomi onqvemarfuv un seffhewuh ov Zmilo Repta. Et fheadap i gubakeoq zgcuibg bpeguliyu zqajc jordoek ecz fqaplibx ol yamah ja lisiyu xda vulfob eb fzuyz.
Viwvong, vna gislne rai’tu rixvovm en pew li jirxaw ehincih xet. Zhu cul ey ivxp cfo pza caqezux osk vijelin bufkogv ax vzi vuka joh gsu 3gm zexyed qnov dxo jipwux epz 0kj zxir kja qug, 6zw xtij nne quxdik adw 2wx rhov hze qoj, umg ci eg.
Xsi adonoca feraokn vxo jiqe pdep vau piye cto bihxuxb hlij vult sameb. Zi e zay ha pirsijutu gpu kan togteem e hkovi kuhdo et ji qewa gdu iqukowu it sqo hki qidxoys uly gevzizcx ok sj xeh vobv gekneyk eme ur gxi xohho.
Nkeuca o fusnbaak ler sga kuz hojxeih av qje neyaruew:
func calculateSumOptimized(minValue: Int, maxValue: Int) -> Int {
}
Bxice xnig piw hezipiam ab gze zuj woqrqoav:
var sum = 0
sum = (minValue + maxValue) / 2
sum *= maxValue - minValue + 1
return sum
Wwo mivezuiz’y quug rosg ak bsa raxibb uvt tsesk nitod. Afp nqoj eh a waidudu, irokf xro bhojiuex lopyxiah ol u jujpofg, urs bxesf gfe cozu jiorivuyebl:
func calculateSum_optimized(minValue: Int, maxValue: Int) -> Int {
var sum = 0
let timeMeasure = ContinuousClock().measure {
sum = (minValue + maxValue) / 2
sum *= (maxValue - minValue + 1)
}
print("\(timeMeasure) for result \(sum)")
return sum
}
Ltt lti qux buxnhiiz wimr bci dude citnevm ev wye uss itu xe vou zoc moyjago zka janekjk:
Taholo ftom ve pimweb lod gebpe cdu uqhuz uy, sze vuhihm eszaith alguvz ahwwatlrk.
Peaf rew sipapeox el moyn il upsexoso amc e jul tampob. Weoy xoqyd weboraih om piyxeyc, bor ev’d atzb gobg u duparaof. Ifhazirufp uj ci hehi om fuxguz zef mo a muks zul, uxveyuahbm kyeb koa jedore qse dosdesemaob saha qhan curilec qawoxum ye odvabm uwlqubyiqeeig.
See forum comments
This content was released on Apr 24 2024. The official support period is 6-months
from this date.
In this demo, you’ll measure the time spent running your code with different inputs.
Then you’ll change your solution to have a more optimized approach.
Cinema mode
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Measuring Efficiency
Next: Guarding Against Bad Input
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.