Developing lightweight computation at the DSG edge
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LightKone
antidote-go-client
Commits
b9d1b368
Commit
b9d1b368
authored
Mar 23, 2018
by
Mathias Weber
Browse files
wip: tests checking performance of many operations
parent
eea9853b
Changes
1
Hide whitespace changes
Inline
Side-by-side
antidoteclient_test.go
View file @
b9d1b368
...
@@ -145,6 +145,37 @@ func TestMap(t *testing.T) {
...
@@ -145,6 +145,37 @@ func TestMap(t *testing.T) {
}
}
}
}
func
TestStatic
(
t
*
testing
.
T
)
{
client
,
err
:=
NewClient
(
Host
{
"127.0.0.1"
,
8087
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
client
.
Close
()
timestamp
:=
time
.
Now
()
.
Unix
()
bucketname
:=
fmt
.
Sprintf
(
"bucket%d"
,
timestamp
)
bucket
:=
Bucket
{[]
byte
(
bucketname
)}
key
:=
Key
(
"keyStatic"
)
tx
:=
client
.
CreateStaticTransaction
()
err
=
bucket
.
Update
(
tx
,
CounterInc
(
key
,
42
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
counterVal
,
err
:=
bucket
.
ReadCounter
(
tx
,
key
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
counterVal
!=
42
{
t
.
Fatalf
(
"Counter value should be 42 but is %d"
,
counterVal
)
}
}
// tests for many updates, not enabled
// this is a bit faster than the sequential one, if number of threads in configured correctly
func
testManyUpdates
(
t
*
testing
.
T
)
{
func
testManyUpdates
(
t
*
testing
.
T
)
{
client
,
err
:=
NewClient
(
Host
{
"127.0.0.1"
,
8087
})
client
,
err
:=
NewClient
(
Host
{
"127.0.0.1"
,
8087
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -156,8 +187,11 @@ func testManyUpdates(t *testing.T) {
...
@@ -156,8 +187,11 @@ func testManyUpdates(t *testing.T) {
key
:=
Key
(
"keyMany"
)
key
:=
Key
(
"keyMany"
)
wg
:=
sync
.
WaitGroup
{}
wg
:=
sync
.
WaitGroup
{}
wg
.
Add
(
10
)
for
k
:=
0
;
k
<
10
;
k
++
{
numThreads
:=
3
wg
.
Add
(
numThreads
)
for
k
:=
0
;
k
<
numThreads
;
k
++
{
go
func
()
{
go
func
()
{
defer
wg
.
Done
()
defer
wg
.
Done
()
for
i
:=
0
;
i
<
10000
;
i
++
{
for
i
:=
0
;
i
<
10000
;
i
++
{
...
@@ -190,7 +224,8 @@ func testManyUpdates(t *testing.T) {
...
@@ -190,7 +224,8 @@ func testManyUpdates(t *testing.T) {
fmt
.
Print
(
counterVal
)
fmt
.
Print
(
counterVal
)
}
}
func
testReadMany
(
t
*
testing
.
T
)
{
// not as fast as the parallel version, but close
func
testManyUpdatesSeq
(
t
*
testing
.
T
)
{
client
,
err
:=
NewClient
(
Host
{
"127.0.0.1"
,
8087
})
client
,
err
:=
NewClient
(
Host
{
"127.0.0.1"
,
8087
})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
@@ -198,7 +233,26 @@ func testReadMany(t *testing.T) {
...
@@ -198,7 +233,26 @@ func testReadMany(t *testing.T) {
defer
client
.
Close
()
defer
client
.
Close
()
bucket
:=
Bucket
{[]
byte
(
"bucket"
)}
bucket
:=
Bucket
{[]
byte
(
"bucket"
)}
key
:=
Key
(
"keyMany"
)
key
:=
Key
(
"keyManySeq"
)
for
i
:=
0
;
i
<
30000
;
i
++
{
tx
,
err
:=
client
.
StartTransaction
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
bucket
.
Update
(
tx
,
CounterInc
(
key
,
1
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
tx
.
Commit
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
i
%
1000
==
0
{
fmt
.
Println
(
i
)
}
}
tx
:=
client
.
CreateStaticTransaction
()
tx
:=
client
.
CreateStaticTransaction
()
counterVal
,
err
:=
bucket
.
ReadCounter
(
tx
,
key
)
counterVal
,
err
:=
bucket
.
ReadCounter
(
tx
,
key
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -208,29 +262,59 @@ func testReadMany(t *testing.T) {
...
@@ -208,29 +262,59 @@ func testReadMany(t *testing.T) {
fmt
.
Print
(
counterVal
)
fmt
.
Print
(
counterVal
)
}
}
func
TestStatic
(
t
*
testing
.
T
)
{
// do not issue too many operations in one transaction, it will blow up the transaction cache!
func
testManyUpdatesSeqInTrans
(
t
*
testing
.
T
)
{
client
,
err
:=
NewClient
(
Host
{
"127.0.0.1"
,
8087
})
client
,
err
:=
NewClient
(
Host
{
"127.0.0.1"
,
8087
})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
defer
client
.
Close
()
defer
client
.
Close
()
timestamp
:=
time
.
Now
()
.
Unix
()
bucketname
:=
fmt
.
Sprintf
(
"bucket%d"
,
timestamp
)
bucket
:=
Bucket
{[]
byte
(
bucketname
)}
key
:=
Key
(
"keyStatic"
)
tx
:=
client
.
CreateStaticTransaction
()
err
=
bucket
.
Update
(
tx
,
CounterInc
(
key
,
42
))
bucket
:=
Bucket
{[]
byte
(
"bucket"
)}
key
:=
Key
(
"keyManySeqTrans"
)
tx
,
err
:=
client
.
StartTransaction
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
counterVal
,
err
:=
bucket
.
ReadCounter
(
tx
,
key
)
for
i
:=
0
;
i
<
30000
;
i
++
{
err
=
bucket
.
Update
(
tx
,
CounterInc
(
key
,
1
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
i
%
1000
==
0
{
fmt
.
Println
(
i
)
}
}
err
=
tx
.
Commit
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
counterVal
!=
42
{
txs
:=
client
.
CreateStaticTransaction
()
t
.
Fatalf
(
"Counter value should be 42 but is %d"
,
counterVal
)
counterVal
,
err
:=
bucket
.
ReadCounter
(
txs
,
key
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
fmt
.
Print
(
counterVal
)
}
func
testReadMany
(
t
*
testing
.
T
)
{
client
,
err
:=
NewClient
(
Host
{
"127.0.0.1"
,
8087
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
client
.
Close
()
bucket
:=
Bucket
{[]
byte
(
"bucket"
)}
key
:=
Key
(
"keyMany"
)
tx
:=
client
.
CreateStaticTransaction
()
counterVal
,
err
:=
bucket
.
ReadCounter
(
tx
,
key
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
fmt
.
Print
(
counterVal
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment