Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit03688b7

Browse files
committed
cleanup
1 parent398e7bc commit03688b7

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

‎contrib/postgres_fdw/tests/dtmbench.cpp‎

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct thread
2929
size_t aborts;
3030
int id;
3131

32-
voidstart(int tid,thread_proc_t proc) {
32+
voidstart(int tid,thread_proc_t proc) {
3333
id = tid;
3434
updates =0;
3535
selects =0;
@@ -38,7 +38,7 @@ struct thread
3838
pthread_create(&t,NULL, proc,this);
3939
}
4040

41-
voidwait() {
41+
voidwait() {
4242
pthread_join(t,NULL);
4343
}
4444
};
@@ -96,7 +96,7 @@ T execQuery( transaction_base& txn, char const* sql, ...)
9696
va_end(args);
9797
result r = txn.exec(buf);
9898
return r[0][0].as(T());
99-
}
99+
}
100100

101101
void*reader(void* arg)
102102
{
@@ -118,32 +118,32 @@ void* reader(void* arg)
118118
}
119119
returnNULL;
120120
}
121-
121+
122122
void*writer(void* arg)
123123
{
124124
thread& t = *(thread*)arg;
125125
connectionconn(cfg.connection);
126126
for (int i =0; i < cfg.nIterations; i++)
127-
{
127+
{
128128
worktxn(conn);
129129
int srcAcc =random() % cfg.nAccounts;
130130
int dstAcc =random() % cfg.nAccounts;
131-
try {
132-
if (random() %100 < cfg.updatePercent) {
131+
try {
132+
if (random() %100 < cfg.updatePercent) {
133133
exec(txn,"update t set v = v - 1 where u=%d", srcAcc);
134134
exec(txn,"update t set v = v + 1 where u=%d", dstAcc);
135135
t.updates +=2;
136-
}else {
136+
}else {
137137
int64_t sum = execQuery<int64_t>(txn,"select v from t where u=%d", srcAcc)
138138
+ execQuery<int64_t>(txn,"select v from t where u=%d", dstAcc);
139-
if (sum > cfg.nIterations*cfg.nWriters || sum < -cfg.nIterations*cfg.nWriters) {
139+
if (sum > cfg.nIterations*cfg.nWriters || sum < -cfg.nIterations*cfg.nWriters) {
140140
printf("Wrong sum=%ld\n", sum);
141141
}
142142
t.selects +=2;
143143
}
144-
txn.commit();
144+
txn.commit();
145145
t.transactions +=1;
146-
}catch (pqxx_exceptionconst& x) {
146+
}catch (pqxx_exceptionconst& x) {
147147
txn.abort();
148148
t.aborts +=1;
149149
i -=1;
@@ -152,13 +152,13 @@ void* writer(void* arg)
152152
}
153153
returnNULL;
154154
}
155-
155+
156156
voidinitializeDatabase()
157157
{
158158
connectionconn(cfg.connection);
159159
int accountsPerShard = (cfg.nAccounts + cfg.nShards -1)/cfg.nShards;
160-
for (int i =0; i < cfg.nShards; i++)
161-
{
160+
for (int i =0; i < cfg.nShards; i++)
161+
{
162162
worktxn(conn);
163163
exec(txn,"alter table t_fdw%i add check (u between %d and %d)", i+1, accountsPerShard*i, accountsPerShard*(i+1)-1);
164164
exec(txn,"insert into t_fdw%i (select generate_series(%d,%d), %d)", i+1, accountsPerShard*i, accountsPerShard*(i+1)-1,0);
@@ -175,15 +175,15 @@ int main (int argc, char* argv[])
175175
return1;
176176
}
177177

178-
for (int i =1; i < argc; i++) {
179-
if (argv[i][0] =='-') {
180-
switch (argv[i][1]) {
178+
for (int i =1; i < argc; i++) {
179+
if (argv[i][0] =='-') {
180+
switch (argv[i][1]) {
181181
case'r':
182182
cfg.nReaders =atoi(argv[++i]);
183183
continue;
184184
case'w':
185185
cfg.nWriters =atoi(argv[++i]);
186-
continue;
186+
continue;
187187
case'a':
188188
cfg.nAccounts =atoi(argv[++i]);
189189
continue;
@@ -213,7 +213,7 @@ int main (int argc, char* argv[])
213213
return1;
214214
}
215215

216-
if (initialize) {
216+
if (initialize) {
217217
initializeDatabase();
218218
printf("%d accounts inserted\n", cfg.nAccounts);
219219
return0;
@@ -229,29 +229,29 @@ int main (int argc, char* argv[])
229229
size_t nSelects =0;
230230
size_t nTransactions =0;
231231

232-
for (int i =0; i < cfg.nReaders; i++) {
232+
for (int i =0; i < cfg.nReaders; i++) {
233233
readers[i].start(i, reader);
234234
}
235-
for (int i =0; i < cfg.nWriters; i++) {
235+
for (int i =0; i < cfg.nWriters; i++) {
236236
writers[i].start(i, writer);
237237
}
238-
239-
for (int i =0; i < cfg.nWriters; i++) {
238+
239+
for (int i =0; i < cfg.nWriters; i++) {
240240
writers[i].wait();
241241
nUpdates += writers[i].updates;
242242
nSelects += writers[i].selects;
243243
nAborts += writers[i].aborts;
244244
nTransactions += writers[i].transactions;
245245
}
246-
246+
247247
running =false;
248248

249-
for (int i =0; i < cfg.nReaders; i++) {
249+
for (int i =0; i < cfg.nReaders; i++) {
250250
readers[i].wait();
251251
nSelects += readers[i].selects;
252252
nTransactions += writers[i].transactions;
253253
}
254-
254+
255255
time_t elapsed =getCurrentTime() - start;
256256

257257
printf(
@@ -260,10 +260,10 @@ int main (int argc, char* argv[])
260260
"\"readers\":%d,\"writers\":%d,\"update_percent\":%d,\"accounts\":%d,\"iterations\":%d ,\"shards\":%d}\n",
261261
(double)(nTransactions*USEC)/elapsed,
262262
nTransactions,
263-
nSelects,
263+
nSelects,
264264
nUpdates,
265265
nAborts,
266-
(int)(nAborts*100/nTransactions),
266+
(int)(nAborts*100/nTransactions),
267267
cfg.nReaders,
268268
cfg.nWriters,
269269
cfg.updatePercent,

‎contrib/postgres_fdw/tests/makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CXX=g++
2-
CXXFLAGS=-g -Wall -O2 -pthread
2+
CXXFLAGS=-g -Wall -O2 -pthread
33

44
all: dtmbench
55

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp