#include #include #include #include #include #define BOOST_ARCHIVE_SOURCE #include #include #include #include #include #include #include #include using namespace std; using namespace boost::archive; int main(int argc, char* argv[]) { char* endptr = 0; long elements; if (argc > 1) { elements = strtol(argv[1], &endptr, 10); } else { elements = 70000; } vector > vec; for (int k = 1; k <= 20; ++k) { double basis = 3.5; deque dubs; for (int j = 1; j <= elements; ++j) { basis *= (1000/999); dubs.push_back(basis); } vec.push_back(dubs); basis += 1; } { filebuf fb; fb.open("ofile", ios_base::out | std::ios_base::binary); binary_oarchive oa(fb); oa << vec; } ifstream ifs("ofile", std::ios_base::binary); binary_iarchive ia(ifs); timeval before_tv, after_tv; struct timezone tz; vector > vec2; gettimeofday(&before_tv, &tz); ia >> vec2; gettimeofday(&after_tv, &tz); if (before_tv.tv_sec != after_tv.tv_sec) { after_tv.tv_usec += 1000000; } long diff = after_tv.tv_usec - before_tv.tv_usec; cout << "Input took (microseconds) " << diff << endl; if (vec != vec2) { cout << "The two vecs are not logically equivalent.\n"; } return 1; }