forked from tarantool/cartridge-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part of tarantool#645 bench: load profile patch (select and update)
user@cartridge-cli % ./cartridge bench --select=30 --update=30 --insert=40 --fill=100000 Tarantool 2.8.2 (Binary) f4897ffe-98dd-40fc-a6f2-21ca8bb52fe7 Parameters: URL: 127.0.0.1:3301 user: guest connections: 10 simultaneous requests: 10 duration: 10 seconds key size: 10 bytes data size: 20 bytes insert: 40 percentages select: 30 percentages update: 30 percentages Data schema | key | value | ------------------------------ | ------------------------------ | random(10) | random(20) The pre-filling of the space has started, because the insert operation is not specified or there was an explicit instruction for pre-filling ... Pre-filling is finished Benchmark start ... Benchmark stop Results: Success operations: 1430826 Failed operations: 0 Request count: 1432454 Time (seconds): 10.000640 Requests per second: 143236
- Loading branch information
1 parent
f04035c
commit 4789502
Showing
7 changed files
with
251 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package bench | ||
|
||
import ( | ||
"math/rand" | ||
"reflect" | ||
|
||
"github.com/FZambia/tarantool" | ||
"github.com/tarantool/cartridge-cli/cli/common" | ||
) | ||
|
||
// Execute insert operation. | ||
func (request InsertRequest) execute() { | ||
_, err := request.tarantoolConnection.Exec( | ||
tarantool.Insert( | ||
benchSpaceName, | ||
[]interface{}{ | ||
common.RandomString(request.ctx.KeySize), | ||
common.RandomString(request.ctx.DataSize), | ||
})) | ||
request.results.incrementRequestsCounters(err) | ||
} | ||
|
||
// Execute select operation. | ||
func (request SelectRequest) execute() { | ||
_, err := request.tarantoolConnection.Exec(tarantool.Call( | ||
request.getRandomTupleCommand, | ||
[]interface{}{rand.Int()})) | ||
request.results.incrementRequestsCounters(err) | ||
} | ||
|
||
// Execute update operation. | ||
func (request UpdateRequest) execute() { | ||
getRandomTupleResponse, err := request.tarantoolConnection.Exec( | ||
tarantool.Call(request.getRandomTupleCommand, | ||
[]interface{}{rand.Int()})) | ||
if err == nil { | ||
data := getRandomTupleResponse.Data | ||
if len(data) > 0 { | ||
key := reflect.ValueOf(data[0]).Index(0).Elem().String() | ||
_, err := request.tarantoolConnection.Exec( | ||
tarantool.Update( | ||
benchSpaceName, | ||
benchSpacePrimaryIndexName, | ||
[]interface{}{key}, | ||
[]tarantool.Op{tarantool.Op( | ||
tarantool.OpAssign( | ||
2, | ||
common.RandomString(request.ctx.DataSize)))})) | ||
request.results.incrementRequestsCounters(err) | ||
} | ||
} | ||
} | ||
|
||
// getNext return next operation in operations sequence. | ||
func (requestsSequence *RequestsSequence) getNext() Request { | ||
// If at the moment the number of remaining requests = 0, | ||
// then find a new generator, which requests count > 0. | ||
// If new generator has requests count = 0, then repeat. | ||
for requestsSequence.currentCounter == 0 { | ||
// Increase the index, which means logical switching to a new generator. | ||
requestsSequence.currentRequestIndex++ | ||
requestsSequence.currentRequestIndex %= len(requestsSequence.requests) | ||
// Get new generator by index. | ||
nextRequestsGenerator := requestsSequence.requests[requestsSequence.currentRequestIndex] | ||
// Get requests count for new operation. | ||
requestsSequence.currentCounter = nextRequestsGenerator.count | ||
} | ||
// Logical taking of a single request. | ||
requestsSequence.currentCounter-- | ||
return requestsSequence.requests[requestsSequence.currentRequestIndex].request | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.