c - C#define 中的常数公式是否会影响效率?
问题描述
我正在阅读一些内核源代码cpufreq_governor.h
并看到了这个:
/*
* The polling frequency depends on the capability of the processor. Default
* polling frequency is 1000 times the transition latency of the processor. The
* governor will work on any processor with transition latency <= 10ms, using
* appropriate sampling rate.
*
* For CPUs with transition latency > 10ms (mostly drivers with CPUFREQ_ETERNAL)
* this governor will not work. All times here are in us (micro seconds).
*/
#define MIN_SAMPLING_RATE_RATIO (2)
#define LATENCY_MULTIPLIER (1000)
#define MIN_LATENCY_MULTIPLIER (20)
#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
将最后一行更改为:
#define TRANSITION_LATENCY_LIMIT (10000000) /* (10 * 1000 * 1000) */
解决方案
将最后一行更改为:
#define TRANSITION_LATENCY_LIMIT (10000000) /* (10 * 1000 * 1000) */
很可能不会有任何区别。
任何半体面的编译器都应该能够10 * 1000 * 1000
在编译时进行计算。
推荐阅读
- jsf-2 - JSF 通过 Ajax 刷新列表不正确
- python - 带有搜索功能的 Rest API 以 JSON 格式显示结果
- c# - WPF DataGrid Highlighting all cells in a column that match the selected cell
- c# - 在 WPF ListBox 中隐藏空组
- powershell - VSTS - “允许脚本访问 OAuth 令牌”去了哪里?
- python - 确定在特定 django 字段管理员中查找哪些字段(select2)
- apache-flink - Apache Flink 中的 SlotSharingGroup 是什么?
- c# - Windows 文件名中 RTL 和 LTR 的混合
- selenium - 我可以将 selenium webdriver 安装到 Visual Studio Code 中吗?
- asp.net - 将调整大小的图像显示为返回值而不是页面内容