import std.core; import iplusplus; using namespace standard; inline void* operator new(size_t s) { return allocate_from_heap(s);} inline void operator delete(void* p) { free_from_heap(p); } int main() { { std::list sm; standard::time stl_build_start; for (int i = 0; i < 1000000; i++) sm.push_back(i); standard::time stl_build_end; std::cout << "stl list build time is: " << stl_build_end - stl_build_start << "\n"; standard::time stl_sort_start; sm.sort(); standard::time stl_sort_end; std::cout << "stl list sort time is: " << stl_sort_end - stl_sort_start << "\n"; std::forward_list stlfl; standard::time stlfl_build_start; for (int i = 0; i < 1000000; i++) stlfl.push_front(i); standard::time stlfl_build_end; std::cout << "stl forward_list build time is: " << stlfl_build_end - stlfl_build_start << "\n"; standard::time stlfl_sort_start; stlfl.sort(); standard::time stlfl_sort_end; std::cout << "stl forward_list sort time is: " << stlfl_sort_end - stlfl_sort_start << "\n"; std::set ss; standard::time stl_ss_build_start; for (int i = 0; i < 1000000; i++) ss.insert(i); standard::time stl_ss_build_end; std::cout << "stl set build time is: " << stl_ss_build_end - stl_ss_build_start << "\n"; standard::set sts; standard::time stl_sts_build_start; for (int i = 0; i < 1000000; i++) sts << i; standard::time stl_sts_build_end; std::cout << "I++ set build time is: " << stl_sts_build_end - stl_sts_build_start << "\n"; std::unordered_set us; standard::time stl_us_build_start; for (int i = 0; i < 1000000; i++) us.insert(i); standard::time stl_us_build_end; std::cout << "stl unordered_set build time is: " << stl_us_build_end - stl_us_build_start << "\n"; std::map stlm; standard::time stl_map_build_start; for (int i = 0; i < 1000000; i++) stlm[i] = i; standard::time stl_map_build_end; std::cout << "stl map build time is: " << stl_map_build_end - stl_map_build_start << "\n"; dictionary dic; standard::time dic_build_start; for (int i = 0; i < 1000000; i++) dic[i] = i; standard::time dic_build_end; std::cout << "I++ dictionary build time is: " << dic_build_end - dic_build_start << "\n"; linked_list s; standard::time ipp_build_start; for (int i = 0; i < 1000000; i++) s << i; standard::time ipp_build_end; std::cout << "Linked list build time is: " << ipp_build_end - ipp_build_start << "\n"; standard::time ipp_sort_start; s.sort(); standard::time ipp_sort_end; std::cout << "Linked list sort time is: " << ipp_sort_end - ipp_sort_start << "\n"; forward_list fl; standard::time fl_build_start; for (int i = 0; i < 1000000; i++) fl << i; standard::time fl_build_end; std::cout << "Forward list build time is: " << fl_build_end - fl_build_start << "\n"; standard::time fl_sort_start; fl.sort(); standard::time fl_sort_end; std::cout << "Forward list sort time is: " << fl_sort_end - fl_sort_start << "\n"; standard::time ipp_copy_start; oarchive oa; oa << s; void* data = oa.allocate(); // data points to the serialized list. iarchive ia(data); linked_list t; ia >> t; oa.free(data); // you should free the data once you are done with it. standard::time ipp_copy_end; std::cout << "I++ serialization/deserialization time is: " << ipp_copy_end - ipp_copy_start << "\n"; list l; standard::time list_build_start; for (int i = 0; i < 1000000; i++) l.push_back(i); standard::time list_build_end; std::cout << "list build time is: " << list_build_end - list_build_start << "\n"; std::vector stlv; standard::time stl_vector_build_start; for (int i = 0; i < 1000000; i++) stlv.push_back(1000000-i); standard::time stl_vector_build_end; std::cout << "stl vector build time is: " << stl_vector_build_end - stl_vector_build_start << "\n"; standard::time stlv_sort_start; sort(stlv.begin(),stlv.end()); standard::time stlv_sort_end; std::cout << "Vector sort time is: " << stlv_sort_end - stlv_sort_start << "\n"; int* ai = new int[1000000]; for (int i = 0; i < 1000000; i++) ai[i] = 1000000 - i; standard::time qsort_start; quick_sort(ai, 1000000); standard::time qsort_end; std::cout << "Quick Sort time is: " << qsort_end - qsort_start << "\n"; delete[] ai; std::cout << "heap allocations: " << get_heap_units() << "\n"; } std::cout << "heap allocations: " << get_heap_units() << "\n"; return 0; }