Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ActiveAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {

defaultConfig {
applicationId 'de.greenrobot.performance.activeandroid'
minSdkVersion rootProject.ext.minSdkVersion
minSdkVersion 14 // due to support-compat lib
targetSdkVersion rootProject.ext.targetSdkVersion

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -25,6 +25,6 @@ android {

dependencies {
androidTestCompile project(':Common')
androidTestCompile 'com.android.support:support-v4:23.0.1'
androidTestCompile 'com.android.support:support-compat:26.1.0'
androidTestCompile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import com.activeandroid.Configuration;
import com.activeandroid.query.Select;

import org.junit.After;
import org.junit.Before;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -21,26 +24,27 @@ public class PerfTestActiveAndroid extends BasePerfTestCase {

private static final String DATABASE_NAME = "active-android.db";

@Override
public void tearDown() throws Exception {
@Before
public void setUp() {
// set up database
Configuration dbConfiguration = new Configuration.Builder(getTargetContext())
.setDatabaseName(DATABASE_NAME)
.addModelClass(IndexedStringEntity.class)
.addModelClass(SimpleEntityNotNull.class)
.create();
ActiveAndroid.initialize(dbConfiguration);
}

@After
public void cleanUp() throws Exception {
if (Cache.isInitialized()) {
ActiveAndroid.dispose();
}
getTargetContext().deleteDatabase(DATABASE_NAME);

super.tearDown();
}

@Override
protected void doIndexedStringEntityQueries() throws Exception {
// set up database
Configuration dbConfiguration = new Configuration.Builder(getTargetContext())
.setDatabaseName(DATABASE_NAME)
.addModelClass(IndexedStringEntity.class)
.create();
ActiveAndroid.initialize(dbConfiguration);
log("Set up database.");

for (int i = 0; i < RUNS; i++) {
log("----Run " + (i + 1) + " of " + RUNS);
indexedStringEntityQueriesRun(getBatchSize());
Expand Down Expand Up @@ -90,18 +94,6 @@ private void indexedStringEntityQueriesRun(int count) {
log("Deleted all entities.");
}

@Override
protected void onRunSetup() throws Exception {
super.onRunSetup();

// set up database
Configuration dbConfiguration = new Configuration.Builder(getTargetContext())
.setDatabaseName(DATABASE_NAME)
.addModelClass(SimpleEntityNotNull.class)
.create();
ActiveAndroid.initialize(dbConfiguration);
}

@Override
protected void doOneByOneCrudRun(int count) throws Exception {
final List<SimpleEntityNotNull> list = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion Cupboard/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ android {

dependencies {
androidTestCompile project(':Common')
androidTestCompile 'nl.qbusict:cupboard:2.1.4'
androidTestCompile 'nl.qbusict:cupboard:2.2.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import org.junit.After;
import org.junit.Before;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -25,39 +28,30 @@ public class PerfTestCupboard extends BasePerfTestCase {
private Cupboard cupboard;
private DatabaseCompartment database;

@Override
public void setUp() throws Exception {
super.setUp();

setUpCupboard();
}

private void setUpCupboard() {
@Before
public void setUp() {
cupboard = new CupboardBuilder().useAnnotations().build();
// set up database
cupboard.register(IndexedStringEntity.class);
cupboard.register(SimpleEntityNotNull.class);
DbHelper dbHelper = new DbHelper(getTargetContext(), DATABASE_NAME, DATABASE_VERSION);
database = cupboard.withDatabase(dbHelper.getWritableDatabase());
}

@Override
public void tearDown() throws Exception {
@After
public void cleanUp() throws Exception {
getTargetContext().deleteDatabase(DATABASE_NAME);

super.tearDown();
}

@Override
protected void doIndexedStringEntityQueries() {
// set up database
cupboard.register(IndexedStringEntity.class);
DbHelper dbHelper = new DbHelper(getTargetContext(), DATABASE_NAME, DATABASE_VERSION);
DatabaseCompartment database = cupboard.withDatabase(dbHelper.getWritableDatabase());
log("Set up database.");

for (int i = 0; i < RUNS; i++) {
log("----Run " + (i + 1) + " of " + RUNS);
indexedStringEntityQueriesRun(database, getBatchSize());
indexedStringEntityQueriesRun(getBatchSize());
}
}

private void indexedStringEntityQueriesRun(DatabaseCompartment database, int count) {
private void indexedStringEntityQueriesRun(int count) {
// create entities
List<IndexedStringEntity> entities = new ArrayList<>(count);
String[] fixedRandomStrings = StringGenerator.createFixedRandomStrings(count);
Expand Down Expand Up @@ -92,16 +86,6 @@ private void indexedStringEntityQueriesRun(DatabaseCompartment database, int cou
log("Deleted all entities.");
}

@Override
protected void onRunSetup() throws Exception {
super.onRunSetup();

// set up database
cupboard.register(SimpleEntityNotNull.class);
DbHelper dbHelper = new DbHelper(getTargetContext(), DATABASE_NAME, DATABASE_VERSION);
database = cupboard.withDatabase(dbHelper.getWritableDatabase());
}

@Override
protected void doOneByOneCrudRun(int count) throws Exception {
final List<SimpleEntityNotNull> list = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion DBFlow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
}
}

def dbflow_version = "3.1.1"
def dbflow_version = "4.1.1"

dependencies {
androidTestCompile project(':Common')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.support.annotation.NonNull;

import com.raizlabs.android.dbflow.config.DatabaseConfig;
import com.raizlabs.android.dbflow.config.FlowConfig;
import com.raizlabs.android.dbflow.config.FlowManager;
import com.raizlabs.android.dbflow.data.Blob;
Expand All @@ -12,6 +13,9 @@
import com.raizlabs.android.dbflow.structure.database.transaction.FastStoreModelTransaction;
import com.raizlabs.android.dbflow.structure.database.transaction.ITransaction;

import org.junit.After;
import org.junit.Before;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand All @@ -25,19 +29,23 @@
*/
public class PerfTestDbFlow extends BasePerfTestCase {

@Override
public void setUp() throws Exception {
super.setUp();

FlowManager.init(new FlowConfig.Builder(getTargetContext()).build());
private static final String DATABASE_NAME = "flowdb";
private static final String DATABASE_EXTENSION = ".db";

@Before
public void setUp() {
FlowManager.init(new FlowConfig.Builder(getTargetContext())
.addDatabaseConfig(DatabaseConfig.builder(FlowDatabase.class)
.databaseName(DATABASE_NAME)
.extensionName(DATABASE_EXTENSION)
.build())
.build());
}

@Override
public void tearDown() throws Exception {
@After
public void cleanUp() {
FlowManager.destroy();
getTargetContext().deleteDatabase(FlowDatabase.NAME + ".db");

super.tearDown();
getTargetContext().deleteDatabase(DATABASE_NAME + DATABASE_EXTENSION);
}

@Override
Expand Down Expand Up @@ -120,6 +128,7 @@ protected void doOneByOneCrudRun(int count) throws Exception {
deleteAll();
}

@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
protected void doBatchCrudRun(int count) throws Exception {
final List<SimpleEntityNotNull> list = new ArrayList<>();
Expand All @@ -144,16 +153,16 @@ protected void doBatchCrudRun(int count) throws Exception {
startClock();
for (int i = 0; i < reloaded.size(); i++) {
SimpleEntityNotNull entity = reloaded.get(i);
long id = entity._id;
boolean simpleBoolean = entity.simpleBoolean;
byte simpleByte = entity.simpleByte;
short simpleShort = entity.simpleShort;
int simpleInt = entity.simpleInt;
long simpleLong = entity.simpleLong;
float simpleFloat = entity.simpleFloat;
double simpleDouble = entity.simpleDouble;
String simpleString = entity.simpleString;
byte[] blob = entity.simpleByteArray.getBlob();
entity.get_id();
entity.isSimpleBoolean();
entity.getSimpleByte();
entity.getSimpleShort();
entity.getSimpleInt();
entity.getSimpleLong();
entity.getSimpleFloat();
entity.getSimpleDouble();
entity.getSimpleString();
entity.getSimpleByteArray().getBlob();
}
stopClock(Benchmark.Type.BATCH_ACCESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.raizlabs.android.dbflow.annotation.Database;

@Database(name = FlowDatabase.NAME, version = FlowDatabase.VERSION)
@Database(version = FlowDatabase.VERSION)
public class FlowDatabase {

public static final String NAME = "flowdb";

public static final int VERSION = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
@Table(database = FlowDatabase.class)
public class IndexedStringEntity extends BaseModel {

@PrimaryKey(autoincrement = false)
public long _id;
@PrimaryKey
long _id;

@Column @Index
public String indexedString;
String indexedString;

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,64 @@
@Table(database = FlowDatabase.class)
public class SimpleEntityNotNull extends BaseModel {

@PrimaryKey(autoincrement = false)
public long _id;
@PrimaryKey
long _id;
@Column
public boolean simpleBoolean;
boolean simpleBoolean;
@Column
public byte simpleByte;
byte simpleByte;
@Column
public short simpleShort;
short simpleShort;
@Column
public int simpleInt;
int simpleInt;
@Column
public long simpleLong;
long simpleLong;
@Column
public float simpleFloat;
float simpleFloat;
@Column
public double simpleDouble;
double simpleDouble;
@Column
public String simpleString;
String simpleString;
@Column
public Blob simpleByteArray;
Blob simpleByteArray;

public long get_id() {
return _id;
}

public boolean isSimpleBoolean() {
return simpleBoolean;
}

public byte getSimpleByte() {
return simpleByte;
}

public short getSimpleShort() {
return simpleShort;
}

public int getSimpleInt() {
return simpleInt;
}

public long getSimpleLong() {
return simpleLong;
}

public float getSimpleFloat() {
return simpleFloat;
}

public double getSimpleDouble() {
return simpleDouble;
}

public String getSimpleString() {
return simpleString;
}

public Blob getSimpleByteArray() {
return simpleByteArray;
}
}
Loading