private void add(Realm realm) { realm.beginTransaction(); for (int i = 0; i < numberOfObjects; i++) { Student student = realm.createObject(Student.class); student.setName(dataGenerator.getStudentName(i)); student.setPoints(dataGenerator.getStudentPoints(i)); student.setCsci(dataGenerator.getCsciBool(i)); student.setStudentid(i); } realm.commitTransaction(); }
public void batchWrite() { Log.i("DataStoreBenchmark", "Realm invoking batch write"); // super.intitalize(); Realm.deleteRealm(realmConfiguration); Realm realm; List<Long> values; long timeStart; values = new ArrayList<>(); realm = Realm.getInstance(realmConfiguration); for (int j = 0; j < numberOfIterations; j++) { System.gc(); timeStart = Debug.threadCpuTimeNanos(); realm.beginTransaction(); for (int i = 0; i < numberOfObjects; i++) { Student student = realm.createObject(Student.class); student.setStudentid(i); student.setName(dataGenerator.getStudentName(i)); student.setCsci(dataGenerator.getCsciBool(i)); student.setPoints(dataGenerator.getStudentPoints(i)); } realm.commitTransaction(); long timeStop = Debug.threadCpuTimeNanos(); long duration = timeStop - timeStart; values.add(duration); } realm.beginTransaction(); realm.clear(Student.class); realm.commitTransaction(); realm.close(); finalvalues.put(BATCH_WRITE, values); System.gc(); }
public void write() { Log.i("DataStoreBenchmark", "Realm invoking write"); // super.intitalize(); Realm.deleteRealm(realmConfiguration); Realm realm; int i; List<Long> values; long timeStart; values = new ArrayList<>(); realm = Realm.getInstance(realmConfiguration); i = 0; for (int j = 0; j < numberOfIterations; j++) { System.gc(); timeStart = Debug.threadCpuTimeNanos(); realm.beginTransaction(); Student student = realm.createObject(Student.class); student.setStudentid(999); student.setName("Student999"); student.setCsci(true); student.setPoints(100); realm.commitTransaction(); i++; long timeStop = Debug.threadCpuTimeNanos(); long duration = timeStop - timeStart; values.add(duration); } realm.beginTransaction(); realm.clear(Student.class); realm.commitTransaction(); realm.close(); finalvalues.put(SIMPLE_WRITE, values); System.gc(); }
public void simpleQuery() { // super.intitalize(); Realm.deleteRealm(realmConfiguration); Log.i("DataStoreBenchmark", "Realm invoking simple query"); Realm realm; List<Long> values; long timeStart; values = new ArrayList<>(); realm = Realm.getInstance(realmConfiguration); add(realm); check(realm); for (int i = 0; i < numberOfIterations; i++) { System.gc(); timeStart = Debug.threadCpuTimeNanos(); RealmResults<Student> students = realm.where(Student.class).equalTo("csci", false).between("points", 80, 100).findAll(); for (Student student : students) { long tmp = student.getStudentid(); } long timeStop = Debug.threadCpuTimeNanos(); long duration = timeStop - timeStart; values.add(duration); } realm.beginTransaction(); realm.clear(Student.class); realm.commitTransaction(); realm.close(); finalvalues.put(SIMPLE_QUERY, values); System.gc(); }