📄 test.c
字号:
#include <stdlib.h>//#include <winsock2.h>//#include <map>//#include <string>//#include <queue>//#include <process.h>//#include <io.h>#include <fcntl.h>/*void test_stl_map();void test_boost();void test_pipe();*/#ifdef __cplusplusextern "C"{#endif void test_my_string_set_ex(); void test_mybuffer(); void test_list(); void test_rbtree(); void test_rbtree1(); void test_ini(); void test_hash(); void test_vector(); void test_map(); void test_hashmap(); void test_string_set(); void test_mystring_set(); void getcallid(char * callid, size_t callid_len); void gettimeofday(struct timeval *ptv, void *tzp); void test_msgparse(); void test_list_ex(); void test_vector_ex(); void test_vector_heap(); void test_deque(); void test_heap(); void test_timer_heap(); void test_timer_thread(); void test_listerner(); void test_heapSort(); void test_quickSort(); void test_insertSort(); void test_avltree(); void test_rhapsody_mem_pool(); void test_binary_search(); void test_ttree(); //void test_queue();#ifdef __cplusplus}#endifint main(){ //::_beginthreadex(NULL, 0, NULL, NULL, 0, NULL); //::_beginthread(NULL, 0, NULL); //test_msgparse(); //printf("\n"); //test_boost(); //printf("\n"); //test_stl_map(); //printf("\n"); //test_queue(); test_ttree(); test_binary_search(); test_timer_heap(); test_listerner(); test_timer_thread(); test_rhapsody_mem_pool(); test_avltree(); test_insertSort(); test_heapSort(); test_quickSort(); test_heap(); test_vector_heap(); test_deque(); test_vector_ex(); test_vector(); test_list_ex(); test_ini(); test_mybuffer(); test_hashmap(); test_hash(); test_list(); test_rbtree(); test_rbtree1(); test_map(); test_string_set(); //test_mystring_set(); //test_my_string_set_ex(); return 0;}#define LOOP_COUNT 100000/*struct stl_mag_key{ //stl_map_key(){} //stl_map_key(stl_mag_key& right) //{ // strncpy(callid, right.callid, sizeof(callid)); //} char callid[32]; bool operator < (const stl_mag_key& right)const { if(strcmp(this->callid, right.callid) > 0) return true; return false; }};*//*void test_stl_map(){ struct timeval tv1; struct timeval tv2; int i = 0; std::map<stl_mag_key,int> stl_map; std::map<stl_mag_key,int>::iterator it; srand(0); gettimeofday(&tv1, 0); for(i = 0; i < LOOP_COUNT; i++) { stl_mag_key key = {0}; getcallid(key.callid, sizeof(key.callid) - 1); stl_map[key] = i; } gettimeofday(&tv2, 0); printf("stl-map添加用时:%f秒\n", tv2.tv_sec - tv1.tv_sec + (tv2.tv_usec - tv1.tv_usec)/1000000.0); srand(0); gettimeofday(&tv1, 0); for(i = 0; i < LOOP_COUNT; i ++) { stl_mag_key key = {0}; getcallid(key.callid, sizeof(key.callid) - 1); stl_map.find(key); } gettimeofday(&tv2, 0); printf("stl-map查找用时:%f秒\n", tv2.tv_sec - tv1.tv_sec + (tv2.tv_usec - tv1.tv_usec)/1000000.0); srand(0); gettimeofday(&tv1, 0); for(i = 0; i < LOOP_COUNT; i ++) { stl_mag_key key = {0}; getcallid(key.callid, sizeof(key.callid) - 1); stl_map.erase(key); } gettimeofday(&tv2, 0); printf("stl-map删除用时:%f秒\n", tv2.tv_sec - tv1.tv_sec + (tv2.tv_usec - tv1.tv_usec)/1000000.0);}void test_queue(){ int i = 0; std::queue<int> q; for(i = 0; i < 1200; i ++) { q.push(i); //q.pop(); } for(i = 0; i < 1000; i ++) { q.push(i); q.pop(); } for(i = 0; i < 1200; i ++) { //q.push(i); q.pop(); }}*///int fdpipe[2] = {0};//int fd = 0;////static void test_pipe_thread(void * param)//{// ::Sleep(3 * 1000);//// ::send(fd, "socket", sizeof("socket"), 0);// ::write(fd, "socket", sizeof("socket"));// ::_write(fd, "socket", sizeof("socket"));//// ::_write(fdpipe[1], "abc", sizeof("abc"));//}////void test_pipe()//{// struct fd_set fd_set1 = {0};// char actemp[32] = {0};// WORD version_requested = MAKEWORD (1, 1);// WSADATA wsa_data;// int error = WSAStartup (version_requested, &wsa_data);// ::_pipe(fdpipe, 256, O_BINARY);////// ::_beginthread(test_pipe_thread, 0, NULL);//// fd = ::socket(AF_INET, SOCK_RAW, PF_INET);//// FD_SET(fd, &fd_set1);// ::select(1, &fd_set1, NULL, NULL, NULL);//// ::recv(fd, actemp, sizeof(actemp), 0);// printf("%s\n", actemp);//// ::_read(fdpipe[0], actemp, sizeof(actemp));// printf("%s\n", actemp);//}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -