| 63 | }; |
| 64 | |
| 65 | static void test(size_t max, bool use_typeid) { |
| 66 | std::vector<myobj*> objs; |
| 67 | |
| 68 | struct timeval begin, end; |
| 69 | gettimeofday(&begin, NULL); |
| 70 | |
| 71 | for (size_t i = 0; i < max; i++) { |
| 72 | myobj* o = new myobj1(use_typeid); |
| 73 | objs.push_back(o); |
| 74 | } |
| 75 | |
| 76 | for (size_t i = 0; i < max; i++) { |
| 77 | myobj* o = new myobj2(use_typeid); |
| 78 | objs.push_back(o); |
| 79 | } |
| 80 | |
| 81 | gettimeofday(&end, NULL); |
| 82 | double tc = acl::stamp_sub(end, begin); |
| 83 | |
| 84 | printf("After add, time cost=%.2f ms, obj: %lld, obj1: %lld, obj2: %lld\r\n", |
| 85 | tc, ACL_COUNTER_COUNT(myobj), ACL_COUNTER_COUNT(myobj1), |
| 86 | ACL_COUNTER_COUNT(myobj2)); |
| 87 | |
| 88 | ACL_COUNTER_PRINT(); |
| 89 | |
| 90 | printf("Enter any key to continue...\r\n"); |
| 91 | getchar(); |
| 92 | |
| 93 | for (std::vector<myobj*>::iterator it = objs.begin(); |
| 94 | it != objs.end(); ++it) { |
| 95 | delete *it; |
| 96 | } |
| 97 | |
| 98 | printf("After del objs: %lld\r\n", ACL_COUNTER_COUNT(myobj)); |
| 99 | ACL_COUNTER_PRINT(); |
| 100 | } |
| 101 | |
| 102 | int main(int argc, char *argv[]) { |
| 103 | // ��ʼ�� acl �� |