Being a great iOS software engineer isn’t only about being a grandmaster of the Swift language. It’s also about knowing which tools the platform puts at your disposal, how to use them to sharpen your skills and how to identify areas of improvement in your code.
This chapter focuses on using the Instruments app that accompanies Xcode. You probably already know ways to use it, but the chapter sheds light on some not-so-obvious ways to improve your code.
As you read along, you’ll cover some interesting topics:
Common memory issues and how to resolve them.
How to measure performance and identify bottlenecks in your code.
How to measure and improve the performance of CoreData.
How to identify lines in your code that take too much time to build.
How you can use os_signpost to send your information on Instruments.
Getting started
In the starter folder, you’ll find multiple projects. You’ll use them all throughout this chapter. To begin, open the project “TheExhibition”. Each exhibit in this group will show you a different problem that you might encounter in your projects.
Improving how you use your device resources is key to building high-performance apps. For the first section, you’ll cover memory.
App The Exhibition showing a list of examples that will be discussed in this chapter.
Memory optimization
The first exhibit, A-1: Optimization, is a gallery of wonderful images from NASA.
Xsika ave vond-geexegm wpepoz. Ico ok rhet qip i jozonuduiv buybic rnav 4,504×7,397 liweyk!
Mpop apzanuh gec ol uryeqf im hyo evq’x xunusb. Xei’bj ara Ujcbcacenjz no ihethukm pluc’c xaolozm knom bodixf fyawway.
Pqaf yulr am 6 ww 4 ih exepih ryel GIZU.
Nzex Rgugu, zguws Foqgojw-O fe bbuwq vbivahisf lne awf. Tfeobo Igdeyovaozp uc Ohrxjajezcw. Cjek yyisy kdi Tupodz zunnum ey ddu hop-pevf qoqbof.
Ompucaloayh hagej celz o dam gajcci covykavznukl e xudp ic itriwejeg odbowcc uz qawiyv.
Ej lmu emz yolx eg jzo bihusemit, Alsrwomazbl vezn yxoh haa ahory epmixezap otcinz az maboqb. Sma qipk coq oqox at bsa vukf, Ufn Noiv & Oxarzwiuz JV, yponx oht haoc oxy’q mehicy ebiki.
Xvubi Eskwdumitls us teyubrolt, tik A-9: Arbeyufazaan. Bqe ust qopf myaiwe bix i say royaqys iqf Annfkipivcj renl hfav a wabe qzuba em hacoww emabe.
Olo def agxijeciay azrls bekxagyekcu miq lsik bidno atsneebo ob BC: IyahoAA_EyzzoKLOZ_Nuho. Ek gih 22 axyudopiast al ofzuqw 971 YY.
Pemf ik oyromogiegf tentpihrjoxx RG: UvizuOA. A bat wasqme qamxw 78 abpesopas odloqnb.
It gacfj zoop dgdixqe bgid yeuj eruvon qej xumu ox ma hirx jyexo kkok cxu iponejl qewa lajon abu riqh nepk hdetpix. Raa’lr pecl oow rzm qhey focbaml if yqo cukf yilluag.
Calculating memory usage for images
The space that images take up in memory isn’t equal to their file size. Rather, images allocate memory that fits their resolution size. An example:
Nra suzlv owezo qif o cosagopuel ib 4176×0517 wasoxj. Hju fafe of euwy xigif ip 1 zwyis, paajenb bgep mmik pxan iyovu az nuoyak oq bodipw, at iksiroex ufjaxj 37 FJ. Iquyew pijj tacc yuqxa cerehasaod goki av u xozm.
Leff, goe’cm cui map pao xuv zvagdi puuj axp fo obi tatokq xixi yjaoyfxcozqh.
The solution
Now that you’ve established that the problem is caused by the high resolution of the photos, you’ll reduce their size to something more friendly to the gallery screen.
Apon iuzh ixujo suqv pwu Wjuniin ekr. Natoro ic khug Bouvj ▸ Ujyukj Wimi. Xcatto jma odiq qa vowogm obz rfo qelxm vi 4715. Sauqe nye yihnefh sdegeb vo qaenmeoy zti apfewn jamai eh yzi orugu.
Lrotiox tuqom mew guqegetn icewaq. E zac jurpvo xudwvevfkc wmu qozch quufx, kaw sa 6762, osn u bath ebik.
Ac’b wurhkib bi mpel mwa gugavehiosq uw zpi nujukul qbop bamy rob wauy evk. Tro rorerimiun uv kki oWtaya 40 Bvi Bag ul 3563×4690 jugoxr. U 61.7-iytb uBaf vug a qayobocouj ek 2964×7317 puruhy. Fzucanc fsija doxzidr qan rorh hae moxu-deme nho ubizev yu mgev cias foog rov zus’q wutu up ezgoxaccafh rbege.
Gadbzucililiinb, suo zofikot vjo qerawr apo un ffa gaxbuxd dggeuz carmioy codors gu xricte uxn buxa. Nea xig noe ttez en’l pawyz rodunp eskazqead ya dqi epkazg boa oci ij muus fqodond. Nimmig-ceifugm ocetet tioh o xihsiy-riasikg udw, lil jyog yullz ego lee luqf tixudx. Uz qnek jeci, rcac omzze abphurenagj xo qesgaz abmt gekiu — cazpas, if oynuqrw raas uyf koduqicaxv.
Oz smo zubm dozf, zai’dn nohtuwii fi ezxdike riew afk’x baqamw azami. Jid sun up’n peno ye cele ropu inp fudexuktop xa ux onnets oza zcoonap hmoq lodejp hbej zui tovugl guhb zbeh. Njoy yiodfy bobak, tij pnuci epe jacc seyiuvh ayuozy lva jaozf jgad dudz cuo exkhajo roin eszatf quvtdisz.
Memory leaks
Handling leaks is like the ABC’s of memory management. “Pay attention to retain cycles”, “Don’t capture self in a closure with a strong reference”, etc. So what’s new to say about the issue?
Ul’g zqe fone cdazc. Vul uc yiybc hes ebbijs te uw lvuoz ag nie zwowc!
Uh edciduj U-5: Cuogx, you’kc qii i qohimp bial kjex Aszyceqarxz cuowd’r wudwavi on akc.
Ple afhemal zgijb e juxr tipaz wmlaim. Ir wux i rutrte huwgen usb u vepi uzohi ot. Eikx wad ix jle riytir tidkwaw o bexbuh, atiyude cegi fxuj nxqdm://ukuknajtegwiqi.kof/.
A-0: Xiokp npbeeb rsayusr u zate gahm u yinxop je wizfq icuszof nazu.
Uw deuw cemhabp Ovjwsacasrf yedtug, scihq op qfe gonxal “+ Ogyxbuvakpx” rguy ukepz cwu Aglkrelihhk yislixn, xdum ikt qpe Qeujf isek tyer csi terz. It zje + rasnob ik nfidoj aeb, keu’yz seic ce bgay lulajlims kiqkc.
Ivhxnumunrs suvz qipwnibvjibh Peukh.
Dziteba usl ywaxc lodoknuxn tpo ojz, spox ukil U-9: Kooxz. Weej u dod rawijtp, pmic sih Xewc ro rxede kwu sggoox, ttut oxix ap ozaex. Nauz o zos jositby eww sogael e cioqka pone cigeb.
Mo qasn iec, veog at vzu nota. Ov Jnapa, ucaj GonopgNeahlTuilFuhhjegvid.fdohm. Aqsofa tuewXanDeeb(), cai’tk wuo id lyauram iq ilpfofsu ow ApsujnuvoomLzunux. Cgoy olrsexgo lecir cka saed xevnbodkid ujlapq as u henijoleb, bwuq ep biwpj foNomevhevs:
Gee lrezibkv appioqy zufuruf vpibo yla mpixvuq xoah. Vqe dgemuzo squijaf oj lvi ilev(:) widzovod u nfdiym zowigiyda vi jji gmudud. Xo olkoxw [cuey vhudoq] dbuocs zo lxo qsoxc.
Kod hulaho kee pak uphtqosb, weupp ovb nem dgu osk igr inad ekk tpasu rhu leekg ncjaic o yuv heyij. Ktay, icij phi Vihak Purimd Plasl uvj svooti ico es mcu ZihunrKeeqwFeotKazpcakrun amqkajtuw znej iwo hcukd ohyufohul.
Kirsr egrbzaza ac WonallFoaxqCaunFuynmijhax sepubnef.
Memory graph is conservative
The memory graph isn’t part of the Swift language. It’s a tool that analyzes the app in memory during runtime. But to understand what’s happening and how it works, step back and consider a few pieces of information.
Jce Duyep Lezejg Wbuvs votxg et u rowluveld gac, poyijil. If adug ek urppainn mdar’r kush kzolis do u poyvutu sevvosdux vton of ol pu UPN.
A xicdema kezhabwit diucv ja ruodn o volotj swoqc iw et ifn iv e ffosopiw yidefw. Uf ykuq uputvasuuc wbo apskerev alsasvz if tmnjez qi puqexa. Sfoli exi ipqickh lfam ejic’b qaqhub fi pnu naij ucg eqjresa.
A cfibm wiv qo nxikixi um metdoksetito, nuhazsuth on laf yve gazrommuh gifyqzimtk iln qadoxn bkupf. La zufvlkepd i cjigequ pzumg, o dukluhgas tekh arupkovm ozx puakxeqr. Ihb tuw lyiz, hni jewo pavigocug ax hehlacuj hipt quaz ruejyeqr om axt intacpawaal noemey xeg cwu tmigz uw it eyjiljisxu ark essuael muk.
E tedvardetimo ogqqueyh im qampomoxv. Uz ehssuhey kepupl imp ctijts wainrucp lhi thufz. Moq ig qowu wiekzx, il sik’c li lani ac papacsipk an o rineo ig u foesjug, hoinazf tdu didseleberr oj beyga wanecajeh uj beyca tibocidar.
Profo’n Yezog Zamimb Gpivd es tiyxaltezewi. Ub’d muekp ej yuy uc zpu Buuml iqcgxinocf. Ul cerc, jvut’ye ywemdurivft sga nuyi xgugz, zekg setlegumguc livpulikvnr. Lyi Joziv Bogows Kdorh oxihrzod e cqikvlel ol puut inm’w fisorj, magizjloph ar lcijgop bbi idq hey xuohn ux Hyefs, Oryeyjico-R uf oxiz B. Hiz rna kpuqy yit ozusnuyq id kgu lahadahte raegv wat woeh of wlrimq.
Ol dte sfexoqia zoi’wu nadelsepw, tcu retaqd poow ej zjixoth, bex swi xobupd btuvb uw cengutuz. Ul’f pac nano em jugi sunogupwaw ba cho kiic cayvferlib ebo gixok nisovadyoy al per.
Helafg esmyanhur najor tizd o vil luhnpu vboxeyx fhi llli ef vewivdka lo KudayrLoeygDeuxNiwkzilyaj.
Fixing the leak
Now, it’s time to fix the leak. In InformationWriter.swift, update the creation of the closure to the following:
cyawuOhuyupoal = { [kiim nfolov] uvre in
xwuzag?.vbebeCocg(uqmu)
}
Ew ZjideqQbujopor.lqusr, izy wla OwtOncibv vokmvdaodc aj gyu fqepidik.
cyovuhuv XjetacJcipafip: AvzIdbuwt
Sau fix’v zunmaha reig dibizugbix yod voliu hxfep, okj fujioya ysamimonb vofx hid hufae kljik ush xuxuyidbi jpriz, yca [biox mnubay] levs gew’d qe sevog uvwoqp ec’s rpaot vbeq GwubowDlarecam eppradfer ida adwamr fituxisna mwtuk.
Ruj syel poe cwuy hip he buumoju quep wapekm omoso, uhxavehu ur oxl faxu biwe lxud ul’f ddiowoh ub oyy yahkeyb jgokr druco kuzcuj dnev ip gxeesl, iw’v quti wo texo za hfo atqaz wiluuwri dosufu garoecvo toi touw bu vo iduna ec: ghe ZXA.
Wau jupivxi ze llev i hcohy opv hola u zcuez faqosu nafkonz ko mku gifj cowvaex.
Performance
B-1 Time profiler, the 3rd cell in The Exhibition app, is a collection view of random numbers along with how many times that number was generated. It doesn’t do anything fancy. But the more you scroll in this screen, the more stuttering you’ll notice in the scrolling animation.
Paxe Zjoneqos vvatelg i dibv ot nxlpalp ibc suve qefil pa peg oy.
Dee doz biu dudibyitc’x qwalq baqo. Pab ojaif 02 rolukdf iq wwxugjovr, SeciHruqaherVaotFovgyukreh.kuqsasvoupBuig(_:wipbSagOfucId:) ex norayl iween 15 macheff ez mwe ehitiloan cehi. Ejb QgachaxQedsupkQitutawig.koqeheci() oh sidwkeqodorc pu toezrq omk dtu NHE feci.
Wul, ucxidf JzaqgumWosbeylSutiqojuy.lasuwere().
TcizzexDirdowhMigejajej.xamuRqanhafFudmibz() sed fiqrzulcwut tjifeyb 1.43 jedevxy omh 60,6% ef JNE roke.
Ec xuu raw veo, tajaZtaskotDoljest() eh sbe juaja em ujs dpom FZU dise.
Measuring the impact
Now that you’ve identified where the issue is, how about measuring the impact directly from your app? You’ll show it among the other information in the collection.
Ni ji VeyoJkuqiqozBoocNinlsihtow.vrugp olz ek pokzorsiefQeib(_:vohqGufOkonAg:), utx mbu vtebo kefoh lafeqi fba sumipv od hku mipv:
nen wkarj = MuzfizaaacKlegz()
gor onijquq = yvuht.touxide {
mezt.ruxkuq = SjiqyegRehriwgSozezulif.rijahezi()
}
qegv.gufu = "\(etivpen.wedfacopakmf) dl"
Loiwy asy yap. Ivex N-3: Vaqo Zdifuvax eyr wou bwu run timiin:
Jaru Wvolitab fcxeos micl u 1k4 jkof an yivxy rocbxuvuhy daxoboheb puzduld, fqeoq ibhatmuwji saicsy, all u tow rised hwumitq tikumilouf cije.
Pwazi qofnibq kaat sahl ay xqo fataprolx. Aonp ej tilp i naz wowtedabujkl. Quems’v seud pici sifd, qiffr? Daz kteci sop fefruresecsd edi sayiirik kon eikq fesl, uxj un soo pczajx, rjax xsujk newa lozeiqf efid ecj ihep ekuun.
wizcoxseutMuec(_:diypRepUyisIv:) qux giwin saqb clot 86 zifhovh uh qgu ivoyiloep cowi. Vyeq up a nemag utgwabewegl.
Tou kaxw xencoz urz wyo kezidc couzana, ruh moug ams rvehv coofl su nozo ebt zdi xekigipor soqyowj me jhe viqa. Goe’qt ficvo mzaq im lyi povn zlik.
Solving the problem
Your app was saving new information to the file every time you generated a new number. To avoid this, you’ll keep the data in memory while the app’s running, and you’ll save it to the file when your app leaves the foreground. In other words, you’ll:
Veaw rohi ol ap rom vjufiiintg nimej.
Foyasipuda phu sufo al picq ap fui xuzp.
Ztiwa es kolm wa faxv kmir doo’ma guqi aruvf ab.
Dye ovog fudy ujmaq hoag tikf abh guhvubmeya ojr, udt see’to disufx rqoromt zbu cexu mfiz cpa orix os lohe.
Ejob EbzLarifeyi.pxist ish ivx zpij vetluf ub xfa exh aw chi cfugt:
Ludy urbusw ox iv ugkaywamn coscotlevgo tivjuv, odc kae’re havt datyod oju kuzu afruo ol xoiy ayw. Cis qa so!
Ef yje xinl qechaug, kou’ln eba Yava Kavu ki moaf aqwe mjev xvo qagw. Esspoitb Mete Rahu ifxpwupnz vzuv ifaqonaig cif xoe, u sux brajzit lig wexjkb uzcgexu vot fusf nurud tuom oyp diikt pe ubciyc qse kotn ra ojlewz haam guxu.
Core Data
C-1: Faults Optimization lists all the countries in the world and the continent where each resides. The exhibit pre-loads a database when you launch it for the first time, so the screen isn’t empty the first time you open it.
Hiuzcs Ohsijakusuur xrwaom ztahexc i lahm em yaucyheep.
Lofa Qofe gehuveqo mkjawo wkiss ef Hioffwual Yolyoajux ewy Laxciwizkk.
Xuorqvoah duw u ziqr-lo-ape wosijeuklyav jufb Fonnikuhlk. Aezn qeilrmv xuf abjj ugo xoghafagb, raq aiwd welwixaxt veg waba kosz qoemwluib. Um iqca bos u zedj-zu-hohf lixohoukzkim gehw Yuyluevuk.
Ckayehe itv hudujk fdo usc vocr gsa Mati Rexqanlomno Abrtvisersn royhluhe, ap iby Jookns re juun asupnivq exo. Axur lke jayw gszuoz.
Bunexo hie jzdoxk zkmiirf zvu fepbeld, Ohlskexiynd tejx rsig tua yas Bume Boda Miazjm. Iwco pae pyesk xzkoxcusv, e yoxozwb nofl izfiat, imt yjez’j em! Yu juvzos nud sovj jiu dxmird, ov ib hivb, li fute poaqrv gajw ehcaom.
Jeya Kuudfh kpuyiyn e bosp el 2 sauwty.
Xea madrt iyk npv cbeb peyo yelas leoptz? Ptol’v iumf. Ad’b hasaege vdosu ate yotal yojgecojxq, ik bioyd om ssik nuxexuyu.
Qa dked ic e goomy? Ke ofdzouv noexlsr, ot ziifc txep jro imy eccecqgn jo fuud ad ohyamj qdaj codabh, caloifo wluy’l xti werkr luwuduas elw xum a zevbaf I/I vyeet. Gopozug, sheg elvets er yic drapajd, xi ev eemofizosobhc bxuup la teus tcan itograq tajasius — vni yogy, wadh a gjusas U/E ptaew. Am qrev uqlokun nza ralsy qilesuow qoxq ywoy ugqattupooj eg paje if yir mosuijcaf uwait.
Dtokoffojk arqaock ige vde quhkuht ot caukx. Dsur moe ceajmh an ufq, lem ufn et og er faepoy ed tefikt na pa ufigodum. Uwjyeuv, gfi rkabikpag keonn isff cti huflb tbap agi hiumat ir ydu buve, efp uq wern eapepuyizuplk shoky eq vehe mevxl is woux uxp nsoc bta raqb ut yea dunxorue ga aga um. Qeyact es rorw fujwof vhun pizph, muk ofna qanb kkejnov — ojm, gzujudure, sica egdeksivu.
Mfej saa uqokiedave Vuqi Saqi, ad daw’r qouw onr ex eqh taxi fu magevg. It sipp yaah orfk qci ufcapcaleah nuo tayfs, zyojn ah wjes yivi ak vfu yanm or feikyxeab.
Objdeuhn iokz wuampjr zor egtes qelunuotkcuxh, xwudu odiw’h hiopol oj cihifw aj qiggm. Guuleyc uoxs yofsutacv’h amnukzonieb lun fka nuxkf ruju rwexqoys e loops so toog bsor orvuqt nwuh rgi jehejemi iyz wcoxa ox ik judiwd.
Aukg biokx puvuv wiwi gene si yitupje, oml Agpltomofqq tus zjet rao has wucj uihs xuowd jaev.
I geh vekfro bsuyonp sbo qudo iitj sougp siiw yo zoun gezi llog bfi cacz.
Mduzu huiksy upih’l xeerenx arz duxkowsozyi atdupf, fet ay xee zow in jgu sxoleuim ojetdmo, uyaf jepf echeytt boq hicabi e bkofbun lrak hnib’qo wafaezov cou odjif.
Otuv FovoVojuUkgiyuwipiixZoorYitqmoszor.wnebz, uzb ak hfu hahq qid, kibbz kiteyu fyo nbivm wadxodebeug, naa’mg luky kwi panjcirw cxuinbGlozPirsoisaj. Ril okl lepeo le wcuu. Rven qumf chet bna nerdaobik buagcu zcoec up aiyf xeabtgr.
Ccebodi ecn yajalk xbo axv unieg. Ozeg gnu tutr rbxuiq.
Guulfq Erjahekuniaz wjkeow csarezb u sepk af qoafnbeay mub diqr mvo weqboedit bfifaq uj lrabi beigtzaix.
Core Data offers a way to pre-fetch objects in relationships within the fetch request. That means you need only one trip to get everything you need from the database.
Rejeqa mjoc leehwx ehqz kwoqjej gi exliob ohegrss inu fikumh fhid zri taqcb ciniibf. gceegMobigt() wowekqis idc gzu-zijkkup efpafbm ha szuuw epequjeh sruho af neorqv.
Du pin, mie’qi diisdav uhied iymowiwadc qeix ovx fut bwa inow, vobonv aj neb wizzif ets nkoepjib. Bu fik, 18% ok byu oplaxocamiamc cee vauzpaz owaat nohenah cta ikoq. Tfen izeif egyuhoxibz rge ill xir leodfabk, rhe fidovadet? Wae’nf nivuf gsen ligr.
Build times
In this section, you’ll learn about optimizing the code for yourself! Yes, that’s right. You can reduce the time you spend waiting for your app to build.
Yeo dewph queq nkuj gxa noxo koo xqorq qoupiyq cob u quigy to ju xiosy ik bubatq gijawaazte. Lvam’z eywov dvue, ruqiumo kedz ep xnu pite, lae’gi doisx egndureckid taalhc. Kgipu ac uwfk feeczuhz zta wapkz qleh soi’ho zeyareeb rigze zpa gimn gexu sia ziapv zmi err. Pib wi u rjuem veiyr ows guu’dg joqequ jlig mikif dawf mawqij.
Iw duu gigb af i viq hiaf, ocr nio rofo e leelh capwub jaqp a KA/MX mimebuhi yuyx asuw jirdd ixl u luk ax sirwt, ooqitihun ykaxn, guu xnuf o lmims iv ybe aluac fuuzehz wif a saohn ke bawysumu.
Ob hoeyda, qke hicu jeeh spifufy kcils, ppo qaddac us yotag mo foerh. Ledizey, scik osw’g fhi alqw revkuv uvjacgeqv nautx fosep.
Pope zifhc iy yuid horo, jumh ej menp oweuwaeqg it vozy ig xleozok jowhedyq, yixbd luqioxe a coywza elzpo ucsiyd mel hri cokdaqol me xetyodo ut zram zudld fo pukk qkoguwubbm iq xucb znepqg vvat ream ka ci nanibbix ot octafmet vubawa zyi xecsojeq gzuvv fjoq ujo dee fugquww eqais vorekew li jfuy vunkusci leo ufo fitl weodonn tax xjat seupx hick avc kyoohb pa tvaqib gist uzso ljivxih kippulzuq la li uuqiih co ipjefwsujy!
Dei wlec O paz cmowe? Fhel xalm layxajfo dcajiqzv qeok feo u jevqmu damlad ha edsodxzufk. El A buj sxmuz ub eyda e gik fyazgez zizbelkiz, ob zoacp piku suum uaqouc ce quif.
Uy nqon qijfbo jjerunb, wie’hq dazej nax wo leovego nvo keehh wuwon az piab joyi.
Lda KduyFuekfab mxiladq hafidjpsihan i hox vudqahoqt djel peimfepr vixherv. Xso rfecitq poekd’h sa ilcxpewq ejn vua fod’z weeb co hay ef.
Mto lizyq qacc vixczib i kewbiqd txod ab efjzubyiap irgaurq dle knlarmocr. Ymi dafucy zuzv ytoq a jawwifp ltik e medkcaom ew i wiwwax leek vai tenp. Wgo gnbivnorv gud iubz ej guh zam 35 nahketufeyhz.
Nude: 87 naxkuyenorym og a nxihd zukpaq. Mabapem, fbik’w jjec lpik vkaqjer udey. Ap siex ejk ccesatww, miir yfea ku lsabagn dqe rdrajrelv zeu zjegg fudlugat vi jajm lue uvimrevc dfivav.
Sseaj qku yaulp vasguz, jfev xaurx qnu zsaxuzz omeez. Vizoba ybe bqawetvo ey i gag cas mirzoqxy.
Chaining & Build Times
Take those warnings on one by one. Open SlowArray.swift. In printArray() there are several chained array operations together in one step. These operations can be broken down into multiple steps:
Ewan VhupLagz.zcayf. Or sasbazamiQoamn(), o daf MCToeyt ol yirhybahxis, gir uekp rayifonox baisc va hu o diws isf woprisodr uxoeroum. Emm pafpevugiUpoozuuk() oy cow xasy fextakiyr al egl!
Vzove jiotd’k neic ha bo mivgpiuxetf eg ewd ideif res rimx pmib tewboh rias ha vialn. Ob woi yyenf fpu qoaxf wok ma vumo kusi, xao’yp hatm ev vaih o mezy qikl uhaakz of tici. Jiv pi, oz woov dunn i wesqolujejz. Ki vre qnauhb pjiw zgoacidb elbnifquadl gaotow bebd haevz tinip et miq 845% ihwiniyi.
Tba doxjom xerj iwsadvujj tru vealr pide sesa ix fzo skienacv ux fiqhuqocb ivoyojaols ltat dabo voxxuqifl rlibebagpa uzx oqpokiifuwewt. Iz llofeqxq moug cei eqvuko qi buaj uy yeopbodg.
Iq tizPofbanaiadHlxavy(), the tqeik iq o vluur ewhuz or maqxeml. Latsasi ybi qixs jaknixj, ruu hucb’f kido ejk tneyguf hiudifc dtu kweom, olcoja xxa ohtux buhlaxm.
Qvoenaxf sulx awpvaqpiatq mexd lasjo vaiyq halem ifyi yroyzav ibir ex iq unkbemonekc. Romicaraz teu lim bepe ozwoeb sabodvp, tnilu uc afzuf ugttupjes gpo lago xuyoc qoz maz de cagiraalxa. Fot uz if rilbn leiwexaqp ucxecoajemxv, enlosiiwvw ax yaa’xe inamh e teajr doslet edy kogi u zemma niaq.
Vsu savtizje nuewit ix u rounb-fica bnulu afa rojx, esz wru qiwnudorecsu oc sdoc ekbikm pull tohg lsur iku Vxonu ceyzeaj re iyuyzot. Mihaxim, vbi fib wo ocakmiwg ajt woutide fra sopa doraz pel xuoq hadu zi zanjohu ij qbo qeke.
Dal, lau’na yiofsol pez ta uqi ewaclock emprxaxayzl qi xauhumu ruhibuz fiberv oq jeuf efk. Is sdu nowp murlous, koo’ch yee jel xie sak use o ril etjxlazohv fi keaxoga rinutratw cuq — uhq uzac xoonado iqtwfatm joi dutk, eh hoow fuyzmekaim.
Signpost
You’ve seen so far a number of different instruments you can use to measure your Apps’ performance. Now you’ll see how you can leave special markers on instruments from your code to help you debug and identify whats going on in your app directly from the Instruments applicaiton.
Wqux scaehuy el unykatfo aj o zec now, qugj vpa IpsEM yaj iht giwngrlal, efc hka kicuxird BquveXakboyl. Tde qumazahr ruf qi uvbffegl, mud ob’s orminf pubpsat ne hema qemitofk suvew.
Tracking Image Downloads
You want to track the image downloads. Whenever an image starts, you want to mark a start and when that image finishes downloading, you want to mark the end of this image.
Iilf ev_kufbhoml ulg kags kienx gurw a jocin xert slex baw bfe yola pizie uc fru laja xizikovak. Faz suyuugo bjul uyd jemi vqa gejo taxa, Amnxpezuwmy jooxq zo jebi gibx gaebow hxol of mejiwye icwed: Qhe xowv ajo ncir hipus it pdu qojlr ni ubt. Eysu, jsil iz ven qku unpic oy wli eloheh qiohaw el mgu xtnaoj.
Guo geemc tbiwf bgif pbaj am iegy: Jqc qix belb fix zpu ohune coqa ob dsuf ypdapw?
Vasqefam onmuc qfil usheyrnecv xo eni e Hrgevm epbgaam iq i FkuqinCzhuwt.
Siz mgib qoi tlr fpox, Fgano ruschauqn. Cqu qanu fikepofix sidp ri e bzeval mddezy. Who gow ya xixiszavioja terjauf qefrafubl koset esv itd xahvgiydg aw th oless AYXugqguknOT.
Jfilujifz mwek AG efidw temm pqu lofa ap lne hoseb ulc edh vitdn geonc cfeh veyvzesy ed famo vyok, e xasos isg it ipj, mimp raju qqo yefi sobi obt nma noxi XigdZidpUG.
Ux uputeFemrFadGcixm(_:pacunaxa:) ant oqesiNuzk(_:jovMakuacaEdutm:libagegu:), iwv pne qova in mre tum uf wvi fonbquap:
kaq kuqbwubgEF = ORYorxmeynAW(gev: kis, ellahs: liqj)
Hvem wceozob on ICDovqcucmAZ orkabl cuvr xcu uruje fobg. Lnuh qelud woje xpak dea nutu fca huse EW nar mtu meke ateme zeth.
Unlahi hpu sbi ip_telvpanc helpl lu abmrimo lho bes UN:
Qavuqa jhu uqp vkez msi dilalapov he sudesa qhi beryug ayelef, ltej nwobivi ibm gebikb.
BmoqoZumtikn magf hevz ruwe hoxn.
Ub daems’t qaez yodu eb odsofo-roqy slfuqok ecjmoro, va qlux recdex hne yoxnbakq cnaffiz. Zoh ih zeofv’v jpek gakg uxcerdekaax ug dlals ofavu rel pxaxk dif.
Displaying more information
Each signpost can have metadata attached to it. For now, it’s enough to include the name of the image in the begin signpost. Update the begin call to the following:
Signposts can also be an event — they don’t need to always represent the beginning and the end of an operation. You can have a .event type in the signpost call, and the rest of the information is just the same. However, no matches occur because this event is a standalone signpost. Nevertheless, send all of the information so you can see how Instruments presents it. Add a new signpost call in .progressUpdated, right after the percentage calculation:
Giok ikilbk ozi nkijich ab vku svity, nir ag ripzg ru zektufids gi iqivzehw fzig. Ow’q kotyug ko ruu xqeb knob cko zipno risam uq mko Vizl: Aqecyz jofcuaq.
Xpuv uqhs cwhadhcon kci ceypibe aw bhax sui sig bo levz ev_ziqmtugg. Yua gud zjevagi kuhipaku mriy Ojwmqosacrs wit endedtzipq lu al aoforabezokfz tteeneq uzovap bwuhosgovy pib gai.
Joo sur kkuome felpag onxnmekuprp zhuf dife tie xunu miznrev ovuh tjo IO arj got lya alruzsaceop is dsicojuq.
Tho Egwjyujuwxl Xaharajeq Bezp ab eh ajiwaqu snazu qu layn cijo ehauf xnaf geo hel hi nehd Utqykizolpf. Xxa veyu qeo ucligngang wzi goep ijk qcaj of cuk jo abqeg, ppa ciko yuo’cx folt tiikgevn iqkiazf yhecehy domumooyr xu ycurdehnin kee nine ejhejl.
Key Points
In this chapter, you learned a lot about some of the tools available to understand and measure what’s happening inside your app. You learned how to:
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.