首页| 行业标准| 论文文档| 电子资料| 图纸模型
购买积分 购买会员 激活码充值

您现在的位置是:团子下载站 > 其他 > 性能和代码空间的折衷

性能和代码空间的折衷

  • 资源大小:0.03 MB
  • 上传时间:2021-08-25
  • 下载次数:0次
  • 浏览次数:26次
  • 资源积分:1积分
  • 标      签: 应用程序 代码 嵌入式系统

资 源 简 介

性能和代码空间的折衷   通常嵌入式系统程序员和拳击手不进行很多比较。然而,在一个方面,他们确实。拳击运动员需要在特定的体重范围内进行战斗,所以他们的挑战是在规定的允许范围内最大限度地发挥他们的效能。嵌入式系统是相似的——你只有有限的内存,你需要在这些限制下最大化你的性能。   通常,提高性能的代码优化也会减少内存大小(通过减少必须存储的代码量)。然而,一些优化要求你做一个权衡-它可以走得更快,也可以更小。做出这个决定是困难的,取决于你正在写的应用程序,但值得注意的是什么是优化属于这一类。本文将介绍您可能遇到的一些主要的空间与速度权衡优化。      Tables vs. calculaTIon   Suppose you want to calculate sin(x/256) for an unsigned 8-bit value x - i.e. the input represents values in the range 0.0 to 1.0. One method would be to calculate a polynomial approximaTIon of the funcTIon. This is likely to be in the order of 5-20 instrucTIons (depending on the architecture)。   Another option would be to have a lookup table. The size of this table will depend on the required output precision. If you wanted 16 bits of output, then the table would be 256 * 16 bits = 512 bytes. This could reduce the calculation to 1 or 2 instructions but at the expense of memory.
VIP VIP