added perf tests in python and java for single key get ranges

This commit is contained in:
Alec Grieser 2017-07-11 19:32:24 -07:00
parent 94f195c6a7
commit 800cbc0ccf
2 changed files with 28 additions and 1 deletions

View File

@ -25,7 +25,6 @@ import com.apple.cie.foundationdb.KeySelector;
import com.apple.cie.foundationdb.Transaction;
import com.apple.cie.foundationdb.TransactionContext;
import com.apple.cie.foundationdb.async.AsyncUtil;
import com.apple.cie.foundationdb.subspace.Subspace;
import com.apple.cie.foundationdb.tuple.ByteArrayUtil;
import java.util.ArrayList;
@ -62,6 +61,7 @@ public class PerformanceTester extends AbstractTester {
SERIAL_GET("Java Completable API serial get throughput"),
GET_RANGE("Java Completable API get_range throughput"),
GET_KEY("Java Completable API get_key throughput"),
GET_SINGLE_KEY_RANGE("Java Completable API get_single_key_range throughput"),
ALTERNATING_GET_SET("Java Completable API alternating get and set throughput"),
WRITE_TRANSACTION("Java Completable API single-key transaction throughput");
@ -109,6 +109,7 @@ public class PerformanceTester extends AbstractTester {
Tests.SERIAL_GET.setFunction(db -> serialGet(db, 2_000));
Tests.GET_RANGE.setFunction(db -> getRange(db, 1_000));
Tests.GET_KEY.setFunction(db -> getKey(db, 2_000));
Tests.GET_SINGLE_KEY_RANGE.setFunction(db -> getSingleKeyRange(db, 2_000));
Tests.ALTERNATING_GET_SET.setFunction(db -> alternatingGetSet(db, 2_000));
Tests.WRITE_TRANSACTION.setFunction(db -> writeTransaction(db, 1_000));
}
@ -345,6 +346,20 @@ public class PerformanceTester extends AbstractTester {
});
}
public Double getSingleKeyRange(TransactionContext tcx, int count) {
return tcx.run(tr -> {
tr.options().setRetryLimit(5);
long start = System.nanoTime();
for (int i = 0; i < count; i++) {
int keyIndex = randomKeyIndex();
tr.getRange(key(keyIndex), key(keyIndex + 1)).asList().join();
}
long end = System.nanoTime();
return count*1_000_000_000.0/(end - start);
});
}
public Double writeTransaction(TransactionContext tcx, int count) {
long start = System.nanoTime();
for (int i = 0; i < count; i++) {

View File

@ -47,6 +47,7 @@ class PythonPerformance(PythonTest):
'serial_get' : 'Python API serial get throughput',
'get_range' : 'Python API get_range throughput',
'get_key' : 'Python API get_key throughput',
'get_single_key_range' : 'Python API get_single_key_range throughput',
'alternating_get_set' : 'Python API alternating get and set throughput',
'write_transaction' : 'Python API single-key transaction throughput',
}
@ -267,6 +268,17 @@ class PythonPerformance(PythonTest):
return count / (time.time() - s)
@fdb.transactional
def run_get_single_key_range(self, tr, count=2000):
tr.options.set_retry_limit(5)
s = time.time()
for i in range(count):
index = random.randint(0, self.key_count)
list(tr[self.key(index):self.key(index+1)])
return count / (time.time() - s)
@fdb.transactional
def single_set(self, tr):
key = self.random_key()