C++操作效率
(1)判断大于(>)的效率低,判断等于(=)的效率高。 (2)i++
和++i
,单独简单使用时,效率相等。 (3)if…else 和 switch…case效率:
- 如果所有选项出现概率相同,结论是:5个选项(包括default)时,switch和if…else相同。低于5个选项if快,高于5个选项switch快。(C++ Footprint and Performance Optimization)
This post is licensed under CC BY 4.0 by the author.