1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/************************************************************************
The test module for the mini-transaction utilities
(c) 1995 Innobase Oy
Created 11/26/1995 Heikki Tuuri
*************************************************************************/
#include "sync0sync.h"
#include "sync0rw.h"
#include "mem0mem.h"
#include "log0log.h"
#include "..\mtr0mtr.h"
#include "..\mtr0log.h"
rw_lock_t rwl[MTR_BUF_MEMO_SIZE];
/*********************************************************************
Test for mtr buffer */
void
test1(void)
/*=======*/
{
ulint i;
mtr_t mtr;
printf("-------------------------------------------\n");
printf("MTR-TEST 1. Test of mtr buffer\n");
mtr_start(&mtr);
for (i = 0; i < MTR_BUF_MEMO_SIZE; i++) {
rw_lock_create(rwl + i);
}
for (i = 0; i < MTR_BUF_MEMO_SIZE; i++) {
rw_lock_s_lock(rwl + i);
mtr_memo_push(&mtr, rwl + i, MTR_MEMO_S_LOCK);
}
mtr_commit(&mtr);
rw_lock_list_print_info();
ut_ad(rw_lock_n_locked() == 0);
}
/************************************************************************
Speed test function. */
void
speed_mtr(void)
/*===========*/
{
mtr_t mtr;
mtr_start(&mtr);
mtr_s_lock(rwl, &mtr);
mtr_s_lock(rwl + 1, &mtr);
mtr_s_lock(rwl + 2, &mtr);
mtr_commit(&mtr);
}
/************************************************************************
Speed test function without mtr. */
void
speed_no_mtr(void)
/*===========*/
{
rw_lock_s_lock(rwl);
rw_lock_s_lock(rwl + 1);
rw_lock_s_lock(rwl + 2);
rw_lock_s_unlock(rwl + 2);
rw_lock_s_unlock(rwl + 1);
rw_lock_s_unlock(rwl);
}
/************************************************************************
Speed test function. */
void
test2(void)
/*======*/
{
ulint tm, oldtm;
ulint i, j;
mtr_t mtr;
byte buf[50];
oldtm = ut_clock();
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
speed_mtr();
}
tm = ut_clock();
printf("Wall clock time for %lu mtrs %lu milliseconds\n",
i, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
speed_no_mtr();
}
tm = ut_clock();
printf("Wall clock time for %lu no-mtrs %lu milliseconds\n",
i, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
for (j = 0; j < 250; j++) {
mlog_catenate_ulint(&mtr, 5, MLOG_1BYTE);
mlog_catenate_ulint(&mtr, i, MLOG_4BYTES);
mlog_catenate_ulint(&mtr, i + 1, MLOG_4BYTES);
mlog_catenate_string(&mtr, buf, 50);
}
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall clock time for %lu log writes %lu milliseconds\n",
i * j, tm - oldtm);
mtr_start(&mtr);
for (j = 0; j < 250; j++) {
mlog_catenate_ulint(&mtr, 5, MLOG_1BYTE);
mlog_catenate_ulint(&mtr, i, MLOG_4BYTES);
mlog_catenate_ulint(&mtr, i + 1, MLOG_4BYTES);
mlog_catenate_string(&mtr, buf, 50);
}
mtr_print(&mtr);
mtr_commit(&mtr);
}
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
oldtm = ut_clock();
sync_init();
mem_init();
log_init();
test1();
test2();
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}
|