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)
- Loading branch information
1 parent
f04035c
commit 1b8c154
Showing
9 changed files
with
222 additions
and
40 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,53 @@ | ||
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)})) | ||
incrementRequest(err, request.results) | ||
} | ||
|
||
// Execute select operation | ||
func (request SelectRequest) execute() { | ||
_, err := request.tarantoolConnection.Exec(tarantool.Call(request.getRandomTupleCommand, []interface{}{rand.Int()})) | ||
incrementRequest(err, request.results) | ||
} | ||
|
||
// 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)))})) | ||
incrementRequest(err, request.results) | ||
} | ||
} | ||
} | ||
|
||
// Return next operation in operations sequence | ||
func (requestsSequence RequestsSequence) getNext() Request { | ||
for requestsSequence.currentCounter == 0 { | ||
requestsSequence.currentRequestIndex++ | ||
requestsSequence.currentRequestIndex %= requestTypesCount | ||
requestsSequence.currentCounter = requestsSequence.requests[requestsSequence.currentRequestIndex].count | ||
} | ||
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
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.