/** @file time_hashmap.cpp * * Timings for exhashmap<> operations. */ /* * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "times.h" template static void run_timing(unsigned size, double &time_insert, double &time_find, double &time_erase) { vector S; T M; timer t; S.reserve(size); for (unsigned i=0; i sizes(s, s+sizeof(s)/sizeof(*s)); vector times_insert, times_find, times_erase; for (vector::const_iterator i = sizes.begin(); i != sizes.end(); ++i) { double time_insert, time_find, time_erase; run_timing< exhashmap >(*i, time_insert, time_find, time_erase); // If you like, you can compare it with this: // run_timing< std::map >(*i, time_insert, time_find, time_erase); times_insert.push_back(time_insert); times_find.push_back(time_find); times_erase.push_back(time_erase); cout << '.' << flush; } if (!result) { cout << " passed "; clog << "(no output)" << endl; } else { cout << " failed "; } // print the report: cout << endl << " size:\t"; copy(sizes.begin(), sizes.end(), ostream_iterator(cout, "\t")); cout << endl << " insert/s:\t"; copy(times_insert.begin(), times_insert.end(), ostream_iterator(cout, "\t")); cout << endl << " find/s:\t"; copy(times_find.begin(), times_find.end(), ostream_iterator(cout, "\t")); cout << endl << " erase/s:\t"; copy(times_erase.begin(), times_erase.end(), ostream_iterator(cout, "\t")); cout << endl; return result; }