Update README.md
This commit is contained in:
39
README.md
39
README.md
@@ -43,7 +43,7 @@ TinySTL
|
|||||||
* deque:100%
|
* deque:100%
|
||||||
* queue:100%
|
* queue:100%
|
||||||
* pair:100%
|
* pair:100%
|
||||||
* list:90%
|
* list:100%
|
||||||
* STL Algorithms:
|
* STL Algorithms:
|
||||||
* fill:100%
|
* fill:100%
|
||||||
* fill_n:100%
|
* fill_n:100%
|
||||||
@@ -303,3 +303,40 @@ TinySTL
|
|||||||
|std::list<int>|10万|189|
|
|std::list<int>|10万|189|
|
||||||
|std::list<int>|100万|1774|
|
|std::list<int>|100万|1774|
|
||||||
|std::list<int>|1000万|17571|
|
|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<int>|1万|0.88|
|
||||||
|
|TinySTL::list<int>|10万|17.621|
|
||||||
|
|TinySTL::list<int>|100万|591.354|
|
||||||
|
|std::list<int>|1万|1.25|
|
||||||
|
|std::list<int>|10万|35.692|
|
||||||
|
|std::list<int>|100万|665.128|
|
||||||
|
|||||||
Reference in New Issue
Block a user