iOSアプリのバッテリー消費を意識する/iosdc2020-ios-battery

0af658ea4f11fa7bf803115451890d4c?s=47 ararajp
September 20, 2020

 iOSアプリのバッテリー消費を意識する/iosdc2020-ios-battery

0af658ea4f11fa7bf803115451890d4c?s=128

ararajp

September 20, 2020
Tweet

Transcript

  1. iOSΞϓϦͷόοςϦʔফඅ Λҙࣝ͢Δ גࣜձࣾZOZOςΫϊϩδʔζ ZOZOTOWN෦ iOSνʔϜ ߥҪ ༐ี Copyright © ZOZO

    Technologies, Inc.
  2. © ZOZO Technologies, Inc. גࣜձࣾZOZOςΫϊϩδʔζ ZOZOTOWN෦ iOSνʔϜ ߥҪ ༐ีʢ͋ΒΒ/ararajpʣ 2006೥

    ϠϑʔגࣜձࣾʢݱɿZϗʔϧσΟϯάεגࣜձࣾʣ 2011೥ גࣜձࣾVASILY 2018೥ גࣜձࣾZOZOςΫϊϩδʔζ 2
  3. © ZOZO Technologies, Inc. ຊ೔ͷ಺༰ 3 ɾڵຯΛ͖͔͚࣋ͬͨͬ ɾόοςϦʔͷॏཁੑ ɾEnergy ɾXcode

    Energy Gauges ɾXcode Energy Logs ɾ࣮ྫ ɾ·ͱΊ
  4. © ZOZO Technologies, Inc. ͜Μͳܦݧ͋Γ·ͤΜ͔ 4

  5. © ZOZO Technologies, Inc. ి஑͕ϠόΠ 5

  6. © ZOZO Technologies, Inc. 6 ʮiPhone͕ΧΠϩΈ͍ͨʹ೤͍…ʯ ʮ͜ͷΞϓϦΛ࢖͍ͬͯΔͱి஑ফඅ͕ૣ͍ؾ͕͢Δ…ʯ ͓ͦΒ͘օ͞Μܦݧ͋Γ·͢ΑͶʁ ͱ͍ͬͨܦݧ΋͋ΔͷͰ͸ͳ͍Ͱ͠ΐ͏͔

  7. © ZOZO Technologies, Inc. ։ൃஈ֊ͷΞϓϦΛ৮͍ͬͯͯɺόοςϦʔফඅ͕໌Β͔ʹૣ͍ Ͳ͏΍ͬͯσόοά͍ͯ͘͠ͷ͕࠷దͳͷͩΖ͏ 7 ڵຯΛ͖͔͚࣋ͬͨͬ

  8. © ZOZO Technologies, Inc. όοςϦʔͷॏཁੑ 8

  9. © ZOZO Technologies, Inc. όοςϦʔফඅ͕Ҿ͖ى͜͢໰୊ 9 iPhone͕1೔࢖͑Δ͔ͱ͍͏͜ͱʹؔΘͬͯ͘Δ iPhone͕࢖͑ͳ͍ͱ͍͏͜ͱ͸ɺଞࣾΞϓϦ΍Ϣʔβʔମݧʹେ͖ͳ ӨڹΛٴ΅͢͜ͱΛҙຯ͢Δ όοςϦʔফඅͷӨڹ͸ඇৗʹ޿ൣғ

    ࣗ෼ͨͪͷΞϓϦ͚ͩͷ໰୊Ͱ͸ͳ͍
  10. © ZOZO Technologies, Inc. Ϣʔβʔͷؔ৺ 10 ɾઃఆ͔ΒΞϓϦຖͷ࢖༻ঢ়گΛ֬ೝͰ͖Δ ɾࢹ֮Խ͞Ε͍ͯΔͷͰϢʔβʔͷ ɹόοςϦʔʹର͢Δؔ৺΋ߴ͍ ফඅ͕େ͖͍ΞϓϦ͸ݏѱײΛ๊͔ΕΔ

  11. © ZOZO Technologies, Inc. Apple΋ॏཁࢹ͍ͯ͠Δ 11 ɾWWDCͰηογϣϯଟ਺ ɾόοςϦʔʹؔ͢ΔΨΠυͷࡦఆ ɾϢʔβʔ޲͚ͷϖʔδ΋ଘࡏ͢Δ

  12. © ZOZO Technologies, Inc. WWDCؔ࿈ηογϣϯ 2013 Energy Best Practices 2014

    Writing Energy Efficient Code 2015 Achieving All-day Battery Life https://developer.apple.com/videos/play/wwdc2015/707/ Debugging Energy Issue https://developer.apple.com/videos/play/wwdc2015/708/ 12
  13. © ZOZO Technologies, Inc. WWDCؔ࿈ηογϣϯ 2016 Optimizing I/O for Performance

    and Battery Life https://developer.apple.com/videos/play/wwdc2016/719/ 2017 Writing Energy Efficient Apps https://developer.apple.com/videos/play/wwdc2017/238/ 2018 What’s New in Energy Debugging https://developer.apple.com/videos/play/wwdc2018/228/ 13
  14. © ZOZO Technologies, Inc. WWDCؔ࿈ηογϣϯ 2019 Improving Battery Life and

    Performance https://developer.apple.com/videos/play/wwdc2019/417/ 2020 Improve performance and battery life in your app https://developer.apple.com/news/?id=q8jd4xub 14
  15. © ZOZO Technologies, Inc. όοςϦʔʹؔ͢ΔΨΠυ 15 Energy Efficiency Guide for

    iOS Apps https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/ ɾGreat battery life. ɾCool device. ༏ΕͨϢʔβʔΤΫεϖϦΤϯεͷ৚݅ͱͯ͠ҎԼͷ2ؚ͕ͭ·Ε͍ͯΔ
  16. © ZOZO Technologies, Inc. Ϣʔβʔ޲͚ͷϖʔδ 16 όοςϦʔ - ύϑΥʔϚϯεʹؔ͢Δώϯτ ɾը໘ͷ໌Δ͞ௐ੔

    ɾ௿ిྗϞʔυ ɾपลԹ౓ https://www.apple.com/jp/batteries/maximizing-performance/
  17. © ZOZO Technologies, Inc. 17 Apple Ϣʔβʔ σϕϩούʔ ʁ ͦΕͧΕͷؔ৺

  18. © ZOZO Technologies, Inc. σϕϩούʔͷؔ৺ 18 όοςϦʔͷύϑΥʔϚϯε͸ͱͯ΋ॏཁͱ͍͏͜ͱ͕Θ͔Δɻ ͔͠͠ɺΫϥογϡϑϦʔ཰΍ىಈ଎౓ͱ͍ͬͨࢦඪʹൺ΂Δͱݟམͱ ͕ͪ͠ ։ൃ୺຤͕ৗʹέʔϒϧʹܨ͕͍ͬͯΔ͔Β

    ফඅྔʹؾ͕͔ͭͳ͍ͳΜͯ͜ͱ΋…
  19. © ZOZO Technologies, Inc. όοςϦʔ͸ͱͯ΋ॏཁ 19 όοςϦʔফඅʢEnergyʣʹؔͯ͠AppleͷυΩϡϝϯτΛݩʹݟ͍ͯ ͖·͠ΐ͏ όοςϦʔʹେ͖ͳӨڹΛٴ΅͍ͯ͠Δ։ൃΛ͍ͯ͠Δਓ͸গͳ͍͔΋ ͠Ε·ͤΜɻ͔͠͠ॏཁͳ͜ͱͳͷͰ஌͓ͬͯ͘͜ͱ͸େ੾Ͱ͢ɻ

  20. © ZOZO Technologies, Inc. 20 Energy

  21. © ZOZO Technologies, Inc. 21 Energy Power x Time ࣮ߦ͢Δ಺༰Ͱফඅྔ͕ҟͳΔ

    ࣌ؒʹΑͬͯফඅྔ͕ҟͳΔ
  22. © ZOZO Technologies, Inc. 22 Power Time Energy

  23. © ZOZO Technologies, Inc. 23 ফඅྔ͸ΞϓϦͷঢ়ଶʹ Αͬͯ΋มΘΔ ɾΞΫςΟϒঢ়ଶ͔ΞΠυϧঢ়ଶ͔ʹΑͬͯফඅྔ͸ҟͳΔ ɾSuspendedʢఀࢭதʣͷ࣌΋Ұఆྔ͸ফඅ͢Δ

  24. © ZOZO Technologies, Inc. 24 Power Time Energy ΞΫςΟϒ ΞΠυϧ

    ΞΫςΟϒ ΞΠυϧ ఀࢭ
  25. © ZOZO Technologies, Inc. 25 Energyͷ2ͭͷཁૉ Overhead ɾඞཁͳϋʔυ΢ΣΞΛγεςϜʹཁٻ͢Δ࣌ʹൃੜ͢ΔΤωϧΪʔ ɾ௚઀͸੍ޚͰ͖ͳ͍ Active

    Energy ɾαϒγεςϜΛ࢖༻͢Δ࣌ʹ࠷ॳʹൃੜ͢ΔΤωϧΪʔ ɾαϒγεςϜΛ࢖༻͢Δ͜ͱͰΧϝϥͳͲʹΞΫηε͢Δ
  26. © ZOZO Technologies, Inc. 26 Power Time Overhead Active Energy

    Active Energy
  27. © ZOZO Technologies, Inc. 27 OverheadͱActive EnergyΛ࠷దԽ͍ͯ͘͜͠ͱͰ όοςϦʔফඅΛ཈͍͑ͯ͘

  28. © ZOZO Technologies, Inc. 28 αϒγεςϜ AppleͷPower Team͕͍͋͛ͯΔӨڹྗ͕େ͖͍4ͭͷαϒγεςϜ Processing Networking

    Location Graphics
  29. © ZOZO Technologies, Inc. 29 ϓϩηογϯά CPUͳͲͷγεςϜࢿݯΛར༻͢Δ࣌ʹΤωϧΪʔΛফඅ ফඅ͕ଟ͘ͳΔཁҼ ɾ࣮ߦ͢Δίʔυ΍ෛՙͷେ͖͞ʹґଘ ɾ࣮ߦ͞ΕΔॲཧ͕૿͑ΔͱফඅΤωϧΪʔ΋૿͑Δ

  30. © ZOZO Technologies, Inc. 30 ωοτϫʔΩϯά Cellular / Wi-Fi /

    BluetoothΛհͯ͠௨৴Λ͢ΔͱΤωϧΪʔΛফඅ ফඅ͕ଟ͘ͳΔཁҼ ɾ௨৴ྔ͕ଟ͍ͱ૿͑Δ ɾωοτϫʔΫϦΫΤετ͕૿͑Ε͹ΤωϧΪʔ΋૿͑Δ
  31. © ZOZO Technologies, Inc. 31 ϩέʔγϣϯ ϩέʔγϣϯͷܾఆ࣌ʹΤωϧΪʔΛফඅ ফඅ͕ଟ͘ͳΔཁҼ ɾফඅྔ͸ਖ਼֬ੑͱස౓ʹґଘ͢Δ
 ɾϩέʔγϣϯܾఆʹ࣌ؒΛ͔͚Δͱফඅྔ͕૿͑Δ

  32. © ZOZO Technologies, Inc. 32 άϥϑΟοΫε GPU΍CPUͱ͍ͬͨϓϩηοα͕ΤωϧΪʔΛফඅ ফඅ͕ଟ͘ͳΔཁҼ ɾϨϯμϦϯά΍ΞχϝʔγϣϯදࣔʹΤωϧΪʔফඅΛ൐͏ ɾϨϯμϦϯάྔ͕ଟ͍΄Ͳফඅ͕૿͑Δ

    ɾΞχϝʔγϣϯ΍UIʹґଘ͠ෳࡶͳΒ૿͑Δ
  33. © ZOZO Technologies, Inc. 33 ڞ௨͍ͯ͠Δ͜ͱ ॲཧ͕૿͑Ε͹ΤωϧΪʔ΋૿͑Δ ॲཧΛݮΒ͢ͱཁ݅Λຬͨͤͳ͔ͬͨΓػೳ͕௿Լ͢Δ
 େࣄͳͷ͸ॲཧΛ࠷దԽ͠ΤωϧΪʔޮ཰ΛߴΊΔ͜ͱ

  34. © ZOZO Technologies, Inc. 34 ࠷దԽͷྫ ɾίϯςϯπͷߋ৽λΠϛϯάͷ޻෉ ɾཁ݅Λຬͨ͢Ґஔ৘ใͷਫ਼౓ʹมߋ ɾΞχϝʔγϣϯʹ͸௿͍ϑϨʔϜϨʔτͷ࢖༻Λݕ౼ ɾAnalyticsͷૹ৴λΠϛϯάΛௐ੔

    ɾetc… ͜ΕΒͷӨڹΛఆྔԽͯ֬͠ೝ → Xcode Energy Gauges
  35. © ZOZO Technologies, Inc. Xcode Energy Gauges 35

  36. © ZOZO Technologies, Inc. 36 Xcode Energy Gauges ɾΤωϧΪʔফඅΛཧղ͠΍͘͢͢Δ

  37. © ZOZO Technologies, Inc. 37 Average Energy Impact ɾΤωϧΪʔͷফඅྔΛ૬ରతʹࣔ͢ήʔδ ɾZero

    / Low / High / VeryHighͷஈ֊͕͋Δ ɾফඅྔΛ૬ରతʹ͍ࣔͯ͠ΔͷͰଥ౰͔൑அ͢Δͷ͕େࣄ ૝ఆ௨Γͳͷ͔σϕϩούʔͷ൑அʹ ҕͶΒΕ͍ͯΔ
  38. © ZOZO Technologies, Inc. 38 Average Component Utilization ɾαϒγεςϜͷ࢖༻཰͕೺ѲͰ͖Δ

  39. © ZOZO Technologies, Inc. 39 ࣌ܥྻάϥϑ ɾΞϓϦέʔγϣϯ࣮ߦதͷ֤ཁૉͷฏۉతͳ࢖༻ঢ়گ͕Θ͔Δ

  40. © ZOZO Technologies, Inc. 40 όοΫάϥ΢ϯυͷঢ়گ ɾόοΫάϥ΢ϯυͷঢ়گ΋೺ѲͰ͖Δ

  41. © ZOZO Technologies, Inc. 41 ৄ͍͠ঢ়گΛ஌Γ͍ͨ࣌ ɾ3ͭͷInstrumentʹΞΫηε ɹɾTime Profile ɹɾNetwork

    Profile ɹɾLocation Profile
  42. © ZOZO Technologies, Inc. 42 ΞϓϦ഑෍ޙ͸Ͳ͏͢Δ͔ ΞϓϦΛӡ༻͍ͯͯ͠௚໘͢Δͷ͕खݩͰ࠶ݱͰ͖ͳ͍ෆ۩߹ ɾ։ൃऀͷ؀ڥͱϢʔβʔͷ؀ڥ͸ҧ͏ ɾ໰͍߹Θͤ΍ϨϏϡʔ͕͋ͬͯ΋࠶ݱ͕Ͱ͖ͳ͍ ഑෍ͨ͠ΞϓϦͷϩάΛ֬ೝ

    → Xcode Energy Logs
  43. © ZOZO Technologies, Inc. Xcode Energy Logs 43

  44. © ZOZO Technologies, Inc. 44 Xcode Energy Logs ɾσόΠε্Ͱੜ੒͞Ε໰୊͕ใࠂ͞ΕΔ ɾTestFlight

    / App Store΁഑෍ࡁͷΞϓϦͷ໰୊͕೺ѲͰ͖Δ ɹɾCPU͕ଟ͘࢖ΘΕΔΠϕϯτ ɹɾ໰୊ͷίʔυ
  45. © ZOZO Technologies, Inc. 45 Xcode Energy Logs ɾੜ੒λΠϛϯά͸1%ͷόοςϦʔ௿Լ͕ൃੜ͢Δ࣌ ɹɾϑΥΞάϥ΢ϯυͰCPU࢖༻཰80%Ҏ্͕3෼Ҏ্

    ɹɾόοΫάϥ΢ϯυͰCPU࢖༻཰80%Ҏ্͕1෼Ҏ্ ɾAppleʹϩάΛૹ৴ ɾApple͕ू໿ͯ͠ϦετΞοϓ͞ΕΔ ɾXcode Energy OrganizerΛ࢖༻ͯ͠Ӿཡ͢Δ
  46. © ZOZO Technologies, Inc. Xcode Energy Organizer 46

  47. © ZOZO Technologies, Inc. 47 Xcode Energy Organizer Energy LogΛӾཡ͢Δπʔϧ

  48. © ZOZO Technologies, Inc. 48 Xcode Energy Organizer Window ->

    Organizer -> Energyλϒ͔Β֬ೝͰ͖Δ ɾ໰୊ͷ಺༰ ɾDevice / iOSͳͲͷϝλ৘ใ ɾελοΫτϨʔε͔Β௚઀໰୊ͷίʔυΛ։͍ͯσόοά
  49. © ZOZO Technologies, Inc. ࣮ྫ 49

  50. © ZOZO Technologies, Inc. 50 App StoreʹϦϦʔε͍ͯ͠ΔZOZOTOWNΞϓϦͷྫ XcodeΛ։͖ɺWindow -> OrganizerΛબ୒

  51. © ZOZO Technologies, Inc. 51 EnergyλϒΛબ୒ ΞϓϦέʔγϣϯͱ֬ೝ͍ͨ͠ϏϧυΛબ୒

  52. © ZOZO Technologies, Inc. 52 ݁Ռ ɾEnergy Logͷ݅਺ɿ20݅ ɾൃੜσόΠεɿ25σόΠεʢෳ਺ͷσόΠεͰൃੜ͍ͯ͠Δ໰୊͕͋Δʣ Xcode

    Energy LogsͰ։ൃதͷײ͕͔֮֬ΊΒΕΔ
  53. © ZOZO Technologies, Inc. 53 ݁Ռ ɾશମతͳ݅਺͸গͳ͍͕ɺͦͷதͰ΋Ұ൪ଟ͔ͬͨͷ͸ ܭଌܥͷϥΠϒϥϦ ɾσόΠε͸iPhone 7

    / iPhone 6s / iPhone SE͕ଟ͍ ࠓճ։ൃதʹܦݧͨ͠ͷ͸͜Ε
  54. © ZOZO Technologies, Inc. ·ͱΊ 54

  55. © ZOZO Technologies, Inc. 55 ·ͱΊ ɾόοςϦʔফඅ͸ϢʔβʔӨڹ͕େ͖͍ ɾσόοάͷͨΊͷπʔϧ͸༻ҙ͞Ε͍ͯΔ ɾॏཁͳͷ͸Energyͱ͍͏؍఺Λ๨Εͳ͍

  56. None