48 template<
class JType_t>
49 int do_main(
int argc,
char **argv,
const char* title)
61 JParser<> zap(
"Auxiliary program to test speed of memory allocation.");
71 catch(
const exception &error) {
72 FATAL(error.what() << endl);
78 cout << endl << title << endl;
80 JTimer timer1(
"Allocate");
81 JTimer timer2(
"Free");
89 for (
int event_count = 0; event_count != numberOfEvents; ++event_count) {
91 buffer.resize(numberOfAllocs);
97 for (
int i = numberOfAllocs; i != 0; --i, ++out) {
104 random_shuffle(buffer.begin(), buffer.end());
108 std::reverse (buffer.begin(), buffer.end());
120 const double factor = 1.0 / (numberOfEvents * numberOfAllocs);
122 timer1.print(cout, factor,
nano_t);
123 timer2.print(cout, factor,
nano_t);
135 int main(
int argc,
char **argv)
137 if (do_main<__A__>(argc, argv,
"C++") != 0)
return 1;
138 if (do_main<__B__>(argc, argv,
"JAllocator") != 0)
return 1;
139 if (do_main<__C__>(argc, argv,
"JRAM") != 0)
return 1;