04 2023 档案

C++性能优化——能用array就不要用unordered_map作为查询表
摘要:unordered_map需要哈希值计算和表查询的开销,当key值为整数且连续,直接用数组作为查询表具有更高的效率。 #include <iostream> #include <chrono> #include <unordered_map> using namespace std; long lo 阅读全文

posted @ 2023-04-13 10:35 七昂的技术之旅 阅读(329) 评论(0) 推荐(0)

C++ STL vector 性能之push_back、emplace_back、reserve
摘要:#include <iostream> #include <vector> #include <chrono> using namespace std; constexpr int N = 10; void timeMeasure(void(*f)()){ auto begin = std::chr 阅读全文

posted @ 2023-04-10 15:15 七昂的技术之旅 阅读(178) 评论(0) 推荐(0)

导航