ano*_*non 1 c++ containers stl
我正在寻找STL的一个变体(如果它没有所有的功能就没关系),它可以在短的编译时间内进行优化- 我会受到延迟编译调试编辑周期的长编译时间的困扰.
我主要对STL的容器感兴趣:vector/map,而不是算法.
谢谢!
查看编译器预编译头文件的选项.例如,在GCC中,传递标题就像它是一个源一样导致它被预编译.
它为我的小测试显着减少了时间,但前提是你不计算预编译的时间:
Shadow:code dkrauss$ ls maps*
maps.cpp maps.h maps2.cpp
Shadow:code dkrauss$ cat maps*
#include "maps.h"
using namespace std;
map<int,int> ints;
map<string, string> strings;
map<int, string> is;
map<string, int> si;
int main() {
bang(ints);
bang(strings);
bang(is);
bang(si);
extern void more();
more();
}
#include <string>
#include <map>
template< class K, class V >
void bang( std::map<K,V> &v ) {
v[ K() ] = V();
v.erase( v.begin() );
}
#include "maps.h"
using namespace std;
map<int,int> ints2;
map<string, string> strings2;
map<int, string> is2;
map<string, int> si2;
void more() {
bang(ints2);
bang(strings2);
bang(is2);
bang(si2);
}
Shadow:code dkrauss$ time g++ maps*.cpp -o maps
real 0m1.091s
user 0m0.857s
sys 0m0.132s
Shadow:code dkrauss$ time g++ maps.h
real 0m0.952s
user 0m0.406s
sys 0m0.110s
Shadow:code dkrauss$ ls maps*
maps maps.cpp maps.h maps.h.gch maps2.cpp
Shadow:code dkrauss$ time g++ maps*.cpp -o maps
real 0m0.718s
user 0m0.552s
sys 0m0.095s
Shadow:code dkrauss$
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
933 次 |
最近记录: |