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

Commitb395714

Browse files
committed
Add output of elapsed time to tests
1 parent1960984 commitb395714

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

‎contrib/pg_dtm/tests/pg_shard_transfers.go‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import (
77
"database/sql"
88
"strconv"
99
"math/rand"
10+
"time"
1011
)
1112

1213
const (
1314
TRANSFER_CONNECTIONS=8
1415
INIT_AMOUNT=10000
1516
N_ITERATIONS=10000
16-
N_ACCOUNTS=100//2*TRANSFER_CONNECTIONS
17+
N_ACCOUNTS=2*100000
1718
)
1819

1920
varcfg="host=127.0.0.1 port=5432 sslmode=disable"
@@ -40,7 +41,7 @@ func prepare_db() {
4041
exec(conn,"drop extension if exists pg_shard CASCADE")
4142
exec(conn,"create extension pg_shard")
4243
exec(conn,"drop table if exists t")
43-
exec(conn,"create table t(u int, v int)")
44+
exec(conn,"create table t(u int primary key, v int)")
4445
exec(conn,"select master_create_distributed_table(table_name := 't', partition_column := 'u')")
4546
exec(conn,"select master_create_worker_shards(table_name := 't', shard_count := 2, replication_factor := 1)")
4647

@@ -56,19 +57,20 @@ func transfer(id int, wg *sync.WaitGroup) {
5657
checkErr(err)
5758
deferconn.Close()
5859

59-
uids1:= []int{1,3,4,5,7,8,10,14}
60-
uids2:= []int{2,6,9,11,12,13,18,21}
61-
6260
fori:=0;i<N_ITERATIONS;i++ {
61+
amount:=1
62+
account1:=rand.Intn(N_ACCOUNTS)
63+
account2:=rand.Intn(N_ACCOUNTS)
6364
exec(conn,"begin")
64-
exec(conn,"update t set v = v + 1 where u="+strconv.Itoa(uids1[rand.Intn(TRANSFER_CONNECTIONS)]))
65-
exec(conn,"update t set v = v - 1 where u="+strconv.Itoa(uids2[rand.Intn(TRANSFER_CONNECTIONS)]))
65+
exec(conn,fmt.Sprintf("update t set v = v - %d where u=%d",amount,account1))
66+
exec(conn,fmt.Sprintf("update t set v = v + %d where u=%d",amount,account2))
67+
6668
// exec(conn, "update t set v = v + 1 where u=1")
6769
// exec(conn, "update t set v = v - 1 where u=2")
6870
exec(conn,"commit")
6971

7072
ifi%1000==0 {
71-
fmt.Printf("%u tx processed.\n",i)
73+
fmt.Printf("%d tx processed.\n",i)
7274
}
7375
}
7476

@@ -100,6 +102,8 @@ func main() {
100102

101103
prepare_db()
102104

105+
start:=time.Now()
106+
103107
transferWg.Add(TRANSFER_CONNECTIONS)
104108
fori:=0;i<TRANSFER_CONNECTIONS;i++ {
105109
gotransfer(i,&transferWg)
@@ -123,7 +127,7 @@ func main() {
123127

124128
// fmt.Println(sum)
125129

126-
fmt.Printf("done\n")
130+
fmt.Printf("Elapsed time %f seconds\n",time.Since(start).Seconds())
127131
}
128132

129133
funcexec(conn*sql.DB,stmtstring) {

‎contrib/pg_dtm/tests/transfers-fdw.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const (
1212
TRANSFER_CONNECTIONS=8
1313
INIT_AMOUNT=10000
1414
N_ITERATIONS=10000
15-
N_ACCOUNTS=100000//TRANSFER_CONNECTIONS
15+
N_ACCOUNTS=100000
1616
ISOLATION_LEVEL="repeatable read"
1717
//ISOLATION_LEVEL = "read committed"
1818
)
@@ -170,6 +170,8 @@ func main() {
170170

171171
prepare_db()
172172

173+
start:=time.Now()
174+
173175
cCommits:=make(chanint)
174176
cAborts:=make(chanint)
175177
progressWg.Add(1)
@@ -189,6 +191,8 @@ func main() {
189191

190192
close(cCommits)
191193
progressWg.Wait()
194+
195+
fmt.Printf("Elapsed time %f seconds\n",time.Since(start).Seconds())
192196
}
193197

194198
funcexec(conn*pgx.Conn,stmtstring,arguments...interface{}) {

‎contrib/pg_dtm/tests/transfers.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ func main() {
212212

213213
prepare_db()
214214

215+
start:=time.Now()
216+
215217
cCommits:=make(chanint)
216218
cAborts:=make(chanint)
217219
goprogress(TRANSFER_CONNECTIONS*N_ITERATIONS,cCommits,cAborts)
@@ -228,7 +230,7 @@ func main() {
228230
running=false
229231
inspectWg.Wait()
230232

231-
fmt.Printf("done\n")
233+
fmt.Printf("Elapsed time %f seconds\n",time.Since(start).Seconds())
232234
}
233235

234236
funcexec(conn*pgx.Conn,stmtstring,arguments...interface{}) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp