This commit is contained in:
邹晓航
2014-12-11 14:43:34 +08:00

View File

@@ -15,7 +15,7 @@ TinySTL
* binary search tree
* AVL tree
* rbtree
* 线段树
* segment tree
* splay tree
* rope
* Van Emde Boas tree
@@ -43,7 +43,7 @@ TinySTL
* deque100%
* queue100%
* pair100%
* list90%
* list100%
* STL Algorithms:
* fill100%
* fill_n100%
@@ -64,6 +64,7 @@ TinySTL
* count100%
* count_if100%
* mismatch100%
* equal100%
* 其他组件:
* circular_buffer100%
* bitmap100%
@@ -303,3 +304,40 @@ TinySTL
|std::list<int>|10万|189|
|std::list<int>|100万|1774|
|std::list<int>|1000万|17571|
####(11):list<int>::sort()
TinySTL::list<int> list1;
std::list<int> list2;
std::default_random_engine dre;
std::uniform_int_distribution<int> id;
const size_t max = 10000;
for (int i = 0; i != max; ++i){
auto n = id(dre);
list1.push_back(n);
list2.push_back(n);
}
double cost1 = 0.0, cost2 = 0.0;
for (int i = 0; i != 100; ++i){
ProfilerInstance::start();
list1.sort();//TinySTL::list<int>
ProfilerInstance::finish();
cost1 += ProfilerInstance::millisecond();
ProfilerInstance::start();
list2.sort();//std::list<int>
ProfilerInstance::finish();
cost2 += ProfilerInstance::millisecond();
}
cout << "TinySTL time: " << cost1 / 100 << "ms" << endl;
cout << "std time: " << cost2 / 100 << "ms" << endl;
|container|quantity|time(ms)|
|---------|--------|--------|
|TinySTL::list&lt;int>|1万|0.88|
|TinySTL::list&lt;int>|10万|17.621|
|TinySTL::list&lt;int>|100万|591.354|
|std::list&lt;int>|1万|1.25|
|std::list&lt;int>|10万|35.692|
|std::list&lt;int>|100万|665.128|