对比带匿名函数的代码,发现其在手机上更耗电、占内存、运行慢。
Analyzing the Resource Utilization of Lambda Functions on Mobile Devices: Case Studies on Kotlin and Swift
- 用匿名函数写代码比传统方式多消耗37%电量
- 内存占用高出29%,执行时间延长18%
- 适合关注性能优化的移动开发者参考
全球数十亿智能手机每日使用时间长,导致整体电力消耗巨大。在此背景下,即使微小的能耗降低也能带来显著节能效果。本研究探讨了在移动端使用匿名函数(Lambda functions)对资源消耗的影响。尽管匿名函数能提升代码可读性和简洁性,但不会增加语言的功能能力。研究对比了使用匿名函数与传统代码结构在电池耗电、内存占用和执行时间上的差异。结果表明,匿名函数在移动设备上引入了显著的资源开销,且未带来额外功能优势。
原文摘要 · Abstract (English)
With billions of smartphones in use globally, the daily time spent on these devices contributes significantly to overall electricity consumption. Given this scale, even minor reductions in smartphone power use could result in substantial energy savings. This study explores the impact of Lambda functions on resource consumption in mobile programming. While Lambda functions are known for enhancing code readability and conciseness, their use does not add to the functional capabilities of a programming language. Our research investigates the implications of using Lambda functions in terms of battery utilization, memory usage, and execution time compared to equivalent code structures without Lambda functions. Our findings reveal that Lambda functions impose a considerable resource overhead on mobile devices without offering additional functionalities.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。