diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-04-08 19:55:32 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-04-08 19:55:32 +0000 |
commit | 7229e7cdc1ca62974275923e6f32e836f2698efc (patch) | |
tree | 8abe375ddd9ffd3d476bf63ff51a221ab8e52d04 /tests/Map_Manager_Test.cpp | |
parent | eb0a7b2aa8e6bf5fc97672d5ec92eeecbe9375fc (diff) | |
download | ATCD-7229e7cdc1ca62974275923e6f32e836f2698efc.tar.gz |
*** empty log message ***
Diffstat (limited to 'tests/Map_Manager_Test.cpp')
-rw-r--r-- | tests/Map_Manager_Test.cpp | 224 |
1 files changed, 137 insertions, 87 deletions
diff --git a/tests/Map_Manager_Test.cpp b/tests/Map_Manager_Test.cpp index 4257a440ab7..04b5a829c75 100644 --- a/tests/Map_Manager_Test.cpp +++ b/tests/Map_Manager_Test.cpp @@ -9,9 +9,9 @@ // Map_Manager_Test.cpp // // = DESCRIPTION -// This is a simple test of the ACE_Map_Manager and -// ACE_Hash_Map_Manager that illustrates how to use the forward -// and reverse iterators. +// This is a simple test of the <ACE_Map_Manager> and +// <ACE_Hash_Map_Manager> that illustrates how to use the forward +// and reverse iterators. // // = AUTHOR // Irfan Pyarali and Douglas C. Schmidt @@ -30,7 +30,6 @@ typedef ACE_Null_Mutex MUTEX; typedef size_t TYPE; - #if defined (ACE_HAS_TEMPLATE_SPECIALIZATION) // We need this template specialization since TYPE is defined as a @@ -63,48 +62,59 @@ test_hash_map_manager (size_t table_size, size_t iterations) for (i = 0; i < iterations; i++) ACE_ASSERT (map.bind (i, i) != -1); -#if 1 { i = 0; - for (HASH_ITERATOR iter = map.begin (); - iter != map.end (); + for (HASH_ITERATOR iter = map.begin (), end = map.end (); + iter != end; iter++, i++) { - HASH_ENTRY &item = *iter; - ACE_UNUSED_ARG (item); - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + HASH_ENTRY &entry = *iter; + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry.ext_id_, + entry.int_id_)); } + ACE_DEBUG ((LM_DEBUG, "\n")); } -#else + { HASH_ITERATOR iterator (map); HASH_ENTRY *entry = 0; + for (entry = 0, i = 0; iterator.next (entry) != 0; iterator.advance (), i++) - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry->ext_id_, + entry->int_id_)); + ACE_DEBUG ((LM_DEBUG, "\n")); } -#endif /* 1 */ -#if 1 { i = iterations - 1; - for (HASH_REVERSE_ITERATOR iter = map.rbegin (); - iter != map.rend (); + for (HASH_REVERSE_ITERATOR iter = map.rbegin (), rend = map.rend (); + iter != rend; iter++, i--) { - HASH_ENTRY &item = *iter; - ACE_UNUSED_ARG (item); - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + HASH_ENTRY &entry = *iter; + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry.ext_id_, + entry.int_id_)); } + ACE_DEBUG ((LM_DEBUG, "\n")); } -#else + { HASH_REVERSE_ITERATOR iterator (map); @@ -112,26 +122,30 @@ test_hash_map_manager (size_t table_size, size_t iterations) for (entry = 0, i = iterations - 1; iterator.next (entry) != 0; iterator.advance (), i--) - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry->ext_id_, + entry->int_id_)); ACE_DEBUG ((LM_DEBUG, "\n")); } -#endif /* 1 */ -#if 1 { i = 0; - for (HASH_MAP_MANAGER::iterator iter = map.begin (); - iter != map.end (); + for (HASH_MAP_MANAGER::iterator iter = map.begin (), end = map.end (); + iter != end; iter++, i++) { - HASH_MAP_MANAGER::ENTRY &item = *iter; - ACE_UNUSED_ARG (item); - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + HASH_MAP_MANAGER::ENTRY &entry = *iter; + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry.ext_id_, + entry.int_id_)); } ACE_DEBUG ((LM_DEBUG, "\n")); } -#else { HASH_MAP_MANAGER::ITERATOR iterator (map); @@ -139,26 +153,31 @@ test_hash_map_manager (size_t table_size, size_t iterations) for (entry = 0, i = 0; iterator.next (entry) != 0; iterator.advance (), i++) - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry->ext_id_, + entry->int_id_)); ACE_DEBUG ((LM_DEBUG, "\n")); } -#endif /* 1 */ -#if 1 { i = iterations - 1; - for (HASH_MAP_MANAGER::reverse_iterator iter = map.rbegin (); - iter != map.rend (); + for (HASH_MAP_MANAGER::reverse_iterator iter = map.rbegin (), rend = map.rend (); + iter != rend; iter++, i--) { - HASH_MAP_MANAGER::ENTRY &item = *iter; - ACE_UNUSED_ARG (item); - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + HASH_MAP_MANAGER::ENTRY &entry = *iter; + ACE_UNUSED_ARG (entry); + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry.ext_id_, + entry.int_id_)); } ACE_DEBUG ((LM_DEBUG, "\n")); } -#else { HASH_MAP_MANAGER::REVERSE_ITERATOR iterator (map); @@ -166,10 +185,13 @@ test_hash_map_manager (size_t table_size, size_t iterations) for (entry = 0, i = iterations - 1; iterator.next (entry) != 0; iterator.advance (), i--) - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry->ext_id_, + entry->int_id_)); ACE_DEBUG ((LM_DEBUG, "\n")); } -#endif /* 1 */ for (i = 0; i < iterations; i++) { @@ -193,43 +215,47 @@ test_map_manager (size_t table_size, size_t iterations) for (i = 0; i < iterations; i++) ACE_ASSERT (map.bind (i, i) != -1); -#if 1 { - ENTRY item; i = 0; - for (ITERATOR iter = map.begin (); - iter != map.end (); i++, iter ++) + for (ITERATOR iter = map.begin (), end = map.end (); + iter != end; + i++, iter ++) { - item = *iter; - ACE_DEBUG ((LM_DEBUG, "%u ", item.int_id_)); + ENTRY &entry = *iter; + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry.ext_id_, + entry.int_id_)); } ACE_DEBUG ((LM_DEBUG, "\n")); } -#else { ITERATOR iterator (map); ENTRY *entry = 0; for (entry = 0, i = 0; iterator.next (entry) != 0; iterator.advance (), i++) - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry->ext_id_, + entry->int_id_)); ACE_DEBUG ((LM_DEBUG, "\n")); } -#endif /* 1 */ -#if 1 { - ENTRY item; + ENTRY entry; i = iterations - 1; - for (REVERSE_ITERATOR iter = map.rbegin (); - iter != map.rend (); i--, iter ++) + for (REVERSE_ITERATOR iter = map.rbegin (), rend = map.rend (); + iter != rend; + i--, iter ++) { - item = *iter; - ACE_DEBUG ((LM_DEBUG, "%u ", item.int_id_)); + entry = *iter; + ACE_DEBUG ((LM_DEBUG, "%u ", entry.int_id_)); } ACE_DEBUG ((LM_DEBUG, "\n")); } -#else { REVERSE_ITERATOR iterator (map); @@ -237,24 +263,25 @@ test_map_manager (size_t table_size, size_t iterations) for (entry = 0, i = iterations - 1; iterator.next (entry) != 0; iterator.advance (), i--) - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry->ext_id_, + entry->int_id_)); ACE_DEBUG ((LM_DEBUG, "\n")); } -#endif /* 1 */ - -#if 1 { - MAP_MANAGER::ENTRY item; + MAP_MANAGER::ENTRY entry; i = 0; - for (MAP_MANAGER::iterator iter = map.begin (); - iter != map.end (); i++, iter ++) + for (MAP_MANAGER::iterator iter = map.begin (), end = map.end (); + iter != end; + i++, iter ++) { - item = *iter; - ACE_DEBUG ((LM_DEBUG, "%u ", item.int_id_)); + entry = *iter; + ACE_DEBUG ((LM_DEBUG, "%u ", entry.int_id_)); } ACE_DEBUG ((LM_DEBUG, "\n")); } -#else { MAP_MANAGER::ITERATOR iterator (map); @@ -262,24 +289,27 @@ test_map_manager (size_t table_size, size_t iterations) for (entry = 0, i = 0; iterator.next (entry) != 0; iterator.advance (), i++) - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry->ext_id_, + entry->int_id_)); ACE_DEBUG ((LM_DEBUG, "\n")); } -#endif /* 1 */ - -#if 1 { - ENTRY item; + ENTRY entry; i = iterations - 1; - for (MAP_MANAGER::reverse_iterator iter = map.rbegin (); - iter != map.rend (); i--, iter ++) + + for (MAP_MANAGER::reverse_iterator iter = map.rbegin (), rend = map.rend (); + iter != rend; + i--, iter ++) { - item = *iter; - ACE_DEBUG ((LM_DEBUG, "%u ", item.int_id_)); + entry = *iter; + ACE_DEBUG ((LM_DEBUG, "%u ", entry.int_id_)); } ACE_DEBUG ((LM_DEBUG, "\n")); } -#else + { MAP_MANAGER::REVERSE_ITERATOR iterator (map); @@ -287,10 +317,13 @@ test_map_manager (size_t table_size, size_t iterations) for (entry = 0, i = iterations - 1; iterator.next (entry) != 0; iterator.advance (), i--) - ACE_DEBUG ((LM_DEBUG, "%d ", i)); + ACE_DEBUG ((LM_DEBUG, + "(%d|%d|%d)", + i, + entry->ext_id_, + entry->int_id_)); ACE_DEBUG ((LM_DEBUG, "\n")); } -#endif /* 1 */ for (i = 0; i < iterations; i++) { @@ -321,12 +354,20 @@ run_test (void (*ptf) (size_t, size_t), timer.elapsed_time (et); - ACE_DEBUG ((LM_DEBUG, "time to test a %d item map for %d iterations using %s\ -n", - table_size, iterations, test_name)); - ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", - et.real_time, et.user_time, et.system_time)); - ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", + ACE_DEBUG ((LM_DEBUG, + "time to test a map of size %d for %d iterations using %s\n", + table_size, + iterations, + test_name)); + + ACE_DEBUG ((LM_DEBUG, + "real time = %f secs, user time = %f secs, system time = %f secs\n", + et.real_time, + et.user_time, + et.system_time)); + + ACE_DEBUG ((LM_DEBUG, + "time per call = %f usecs\n", (et.real_time / double (iterations)) * 1000000)); } @@ -340,11 +381,21 @@ main (int argc, char *argv[]) if (argc > 1) table_size = ACE_OS::atoi (argv[1]); + if (argc > 2) iterations = ACE_OS::atoi (argv[2]); - run_test (&test_hash_map_manager, table_size, iterations, "Hash_Map_Manager"); - run_test (&test_map_manager, table_size, iterations, "Map_Manager"); + // Test the <ACE_Hash_Map_Manager>. + run_test (&test_hash_map_manager, + table_size, + iterations, + "Hash_Map_Manager"); + + // Test the <ACE_Map_Manager>. + run_test (&test_map_manager, + table_size, + iterations, + "Map_Manager"); ACE_END_TEST; return 0; @@ -376,7 +427,6 @@ template class ACE_Map_Entry<TYPE, TYPE>; #else /* ACE_HAS_TEMPLATE_SPECIALIZATION */ - int main (int argc, char *argv[]) { |