📄 tstcur.c
字号:
btr_pcur_open(tree, tuple, PAGE_CUR_GE, BTR_SEARCH_LEAF, &cursor, &mtr); mtr_commit(&mtr); } tm = ut_clock(); printf("Wall time for test %lu milliseconds\n", tm - oldtm); rnd = 0; oldtm = ut_clock(); for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) { mtr_start(&mtr); rnd = (rnd + 35608971) % 200000 + 1; dtuple_gen_test_tuple3(tuple, rnd, buf); mtr_commit(&mtr); } tm = ut_clock(); printf("Wall time for test %lu milliseconds\n", tm - oldtm); /* btr_print_tree(tree, 3); */#endif mem_heap_free(heap);}#ifdef notdefined mtr_start(&mtr); block = buf_page_create(0, 5, &mtr); buf_page_x_lock(block, &mtr); frame = buf_block_get_frame(block); page = page_create(frame, &mtr); for (i = 0; i < 512; i++) { rnd = (rnd + 534671) % 512; if (i % 27 == 0) { ut_a(page_validate(page, index)); } dtuple_gen_test_tuple(tuple, rnd);/* dtuple_print(tuple);*/ page_cur_search(page, tuple, PAGE_CUR_G, &cursor); rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr); ut_a(rec); rec_validate(rec);/* page_print_list(page, 151); */ }/* page_print_list(page, 151); */ ut_a(page_validate(page, index)); ut_a(page_get_n_recs(page) == 512); for (i = 0; i < 512; i++) { rnd = (rnd + 7771) % 512; if (i % 27 == 0) { ut_a(page_validate(page, index)); } dtuple_gen_test_tuple(tuple, rnd);/* dtuple_print(tuple);*/ page_cur_search(page, tuple, PAGE_CUR_G, &cursor); page_cur_delete_rec(&cursor, &mtr); ut_a(rec); rec_validate(rec);/* page_print_list(page, 151); */ } ut_a(page_get_n_recs(page) == 0); ut_a(page_validate(page, index)); page = page_create(frame, &mtr); rnd = 311; for (i = 0; i < 512; i++) { rnd = (rnd + 1) % 512; if (i % 27 == 0) { ut_a(page_validate(page, index)); } dtuple_gen_test_tuple(tuple, rnd);/* dtuple_print(tuple);*/ page_cur_search(page, tuple, PAGE_CUR_G, &cursor); rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr); ut_a(rec); rec_validate(rec);/* page_print_list(page, 151); */ } ut_a(page_validate(page, index)); ut_a(page_get_n_recs(page) == 512); rnd = 217; for (i = 0; i < 512; i++) { rnd = (rnd + 1) % 512; if (i % 27 == 0) { ut_a(page_validate(page, index)); } dtuple_gen_test_tuple(tuple, rnd);/* dtuple_print(tuple);*/ page_cur_search(page, tuple, PAGE_CUR_G, &cursor); page_cur_delete_rec(&cursor, &mtr); ut_a(rec); rec_validate(rec);/* page_print_list(page, 151); */ } ut_a(page_validate(page, index)); ut_a(page_get_n_recs(page) == 0); page = page_create(frame, &mtr); rnd = 291; for (i = 0; i < 512; i++) { rnd = (rnd - 1) % 512; if (i % 27 == 0) { ut_a(page_validate(page, index)); } dtuple_gen_test_tuple(tuple, rnd);/* dtuple_print(tuple);*/ page_cur_search(page, tuple, PAGE_CUR_G, &cursor); rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr); ut_a(rec); rec_validate(rec);/* page_print_list(page, 151); */ } ut_a(page_validate(page, index)); ut_a(page_get_n_recs(page) == 512); rnd = 277; for (i = 0; i < 512; i++) { rnd = (rnd - 1) % 512; if (i % 27 == 0) { ut_a(page_validate(page, index)); } dtuple_gen_test_tuple(tuple, rnd);/* dtuple_print(tuple);*/ page_cur_search(page, tuple, PAGE_CUR_G, &cursor); page_cur_delete_rec(&cursor, &mtr); ut_a(rec); rec_validate(rec);/* page_print_list(page, 151); */ } ut_a(page_validate(page, index)); ut_a(page_get_n_recs(page) == 0); mtr_commit(&mtr); mem_heap_free(heap);}/*********************************************************************Test for index page. */void test2(void)/*=======*/{ page_t* page; dtuple_t* tuple; mem_heap_t* heap; ulint i, j; ulint rnd = 0; rec_t* rec; page_cur_t cursor; dict_index_t* index; dict_table_t* table; buf_block_t* block; buf_frame_t* frame; ulint tm, oldtm; byte buf[8]; mtr_t mtr; printf("-------------------------------------------------\n"); printf("TEST 2. Speed test\n"); oldtm = ut_clock(); for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) { ut_memcpy(bigbuf, bigbuf + 800, 800); } tm = ut_clock(); printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n", i, tm - oldtm); oldtm = ut_clock(); rnd = 0; for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) { ut_memcpy(bigbuf + rnd, bigbuf + rnd + 800, 800); rnd += 1600; if (rnd > 995000) { rnd = 0; } } tm = ut_clock(); printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n", i, tm - oldtm); heap = mem_heap_create(0); table = dict_table_create("TS_TABLE2", 2); dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0); dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0); ut_a(0 == dict_table_publish(table)); index = dict_index_create("TS_TABLE2", "IND2", 0, 2, 0); dict_index_add_field(index, "COL1", 0); dict_index_add_field(index, "COL2", 0); ut_a(0 == dict_index_publish(index)); index = dict_index_get("TS_TABLE2", "IND2"); ut_a(index); tuple = dtuple_create(heap, 2); oldtm = ut_clock(); rnd = 677; for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) { mtr_start(&mtr); block = buf_page_create(0, 5, &mtr); buf_page_x_lock(block, &mtr); frame = buf_block_get_frame(block); page = page_create(frame, &mtr); for (j = 0; j < 250; j++) { rnd = (rnd + 54841) % 1000; dtuple_gen_test_tuple2(tuple, rnd, buf); page_cur_search(page, tuple, PAGE_CUR_G, &cursor); rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr); ut_a(rec); } mtr_commit(&mtr); } tm = ut_clock(); printf("Wall time for insertion of %lu recs %lu milliseconds\n", i * j, tm - oldtm); mtr_start(&mtr); block = buf_page_get(0, 5, &mtr); buf_page_s_lock(block, &mtr); page = buf_block_get_frame(block); ut_a(page_validate(page, index)); mtr_commit(&mtr); oldtm = ut_clock(); rnd = 677; for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) { mtr_start(&mtr); block = buf_page_create(0, 5, &mtr); buf_page_x_lock(block, &mtr); frame = buf_block_get_frame(block); page = page_create(frame, &mtr); for (j = 0; j < 250; j++) { rnd = (rnd + 54841) % 1000; dtuple_gen_test_tuple2(tuple, rnd, buf); } mtr_commit(&mtr); } tm = ut_clock(); printf( "Wall time for %lu empty loops with page create %lu milliseconds\n", i * j, tm - oldtm); oldtm = ut_clock(); for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) { mtr_start(&mtr); block = buf_page_create(0, 5, &mtr); buf_page_x_lock(block, &mtr); frame = buf_block_get_frame(block); page = page_create(frame, &mtr); rnd = 100; for (j = 0; j < 250; j++) { rnd = (rnd + 1) % 1000; dtuple_gen_test_tuple2(tuple, rnd, buf); page_cur_search(page, tuple, PAGE_CUR_G, &cursor); rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr); ut_a(rec); } mtr_commit(&mtr); } tm = ut_clock(); printf( "Wall time for sequential insertion of %lu recs %lu milliseconds\n", i * j, tm - oldtm); oldtm = ut_clock(); for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) { mtr_start(&mtr); block = buf_page_create(0, 5, &mtr); buf_page_x_lock(block, &mtr); frame = buf_block_get_frame(block); page = page_create(frame, &mtr); rnd = 500; for (j = 0; j < 250; j++) { rnd = (rnd - 1) % 1000; dtuple_gen_test_tuple2(tuple, rnd, buf); page_cur_search(page, tuple, PAGE_CUR_G, &cursor); rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr); ut_a(rec); } mtr_commit(&mtr); } tm = ut_clock(); printf( "Wall time for descend. seq. insertion of %lu recs %lu milliseconds\n", i * j, tm - oldtm); oldtm = ut_clock(); for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) { mtr_start(&mtr); block = buf_page_create(0, 5, &mtr); buf_page_x_lock(block, &mtr); frame = buf_block_get_frame(block); page = page_create(frame, &mtr); rnd = 677; for (j = 0; j < 250; j++) { rnd = (rnd + 54841) % 1000; dtuple_gen_test_tuple2(tuple, rnd, buf); page_cur_search(page, tuple, PAGE_CUR_G, &cursor); rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr); ut_a(rec); } rnd = 677; for (j = 0; j < 250; j++) { rnd = (rnd + 54841) % 1000; dtuple_gen_test_tuple2(tuple, rnd, buf); page_cur_search(page, tuple, PAGE_CUR_G, &cursor); page_cur_delete_rec(&cursor, &mtr); } ut_a(page_get_n_recs(page) == 0); mtr_commit(&mtr); } tm = ut_clock(); printf("Wall time for insert and delete of %lu recs %lu milliseconds\n", i * j, tm - oldtm); mtr_start(&mtr); block = buf_page_create(0, 5, &mtr); buf_page_x_lock(block, &mtr); frame = buf_block_get_frame(block); page = page_create(frame, &mtr); rnd = 677; for (j = 0; j < 250; j++) { rnd = (rnd + 54841) % 1000; dtuple_gen_test_tuple2(tuple, rnd, buf); page_cur_search(page, tuple, PAGE_CUR_G, &cursor); rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr); ut_a(rec); } ut_a(page_validate(page, index)); mtr_print(&mtr); oldtm = ut_clock(); for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) { rnd = 677; for (j = 0; j < 250; j++) { rnd = (rnd + 54841) % 1000; dtuple_gen_test_tuple2(tuple, rnd, buf); page_cur_search(page, tuple, PAGE_CUR_G, &cursor); } } tm = ut_clock(); printf("Wall time for search of %lu recs %lu milliseconds\n", i * j, tm - oldtm); oldtm = ut_clock(); for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) { rnd = 677; for (j = 0; j < 250; j++) { rnd = (rnd + 54841) % 1000; dtuple_gen_test_tuple2(tuple, rnd, buf); } } tm = ut_clock(); printf("Wall time for %lu empty loops %lu milliseconds\n", i * j, tm - oldtm); mtr_commit(&mtr);}#endif/********************************************************************Main test function. */void main(void) /*======*/{ ulint tm, oldtm; mtr_t mtr; sync_init(); mem_init(); os_aio_init(160, 5); fil_init(25); buf_pool_init(POOL_SIZE, POOL_SIZE); fsp_init(); log_init(); create_files(); init_space(); mtr_start(&mtr); trx_sys_create(&mtr); dict_create(&mtr); mtr_commit(&mtr); oldtm = ut_clock(); ut_rnd_set_seed(19); test1();/* mem_print_info(); */ tm = ut_clock(); printf("Wall time for test %lu milliseconds\n", tm - oldtm); printf("TESTS COMPLETED SUCCESSFULLY!\n");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -