Exemplo n.º 1
0
MojErr MojDbPerfCreateTest::testCreate()
{
	MojDb db;

	MojErr err = db.open(MojDbTestDir);
	MojTestErrCheck(err);

	// time put kind
	MojUInt64 putKindTime = 0;
	for (int i = 0; i < numRepetitions; i++) {
		err = putKinds(db, putKindTime);
		MojTestErrCheck(err);
		err = delKinds(db);
		MojTestErrCheck(err);
	}

	err = MojPrintF("\n -------------------- \n");
	MojTestErrCheck(err);
	err = MojPrintF("   putKind took: %llu nanosecs", (putKindTime / (numKinds * numRepetitions)));
	MojTestErrCheck(err);
	err = MojPrintF("\n\n");
	MojTestErrCheck(err);

	MojString buf;
	err = buf.format("put Kind,all %llu kinds,%llu,%llu,%llu,\n", numKinds, putKindTime, putKindTime/numRepetitions, putKindTime / (numKinds * numRepetitions));
	MojTestErrCheck(err);
	err = fileWrite(file, buf);
	MojTestErrCheck(err);

	// insert objects with one index
	err = testInsertSmallObj(db, MojPerfSmKindId);
	MojTestErrCheck(err);
	err = testInsertMedObj(db, MojPerfMedKindId);
	MojTestErrCheck(err);
	err = testInsertLgObj(db, MojPerfLgKindId);
	MojTestErrCheck(err);
	err = testInsertMedNestedObj(db, MojPerfMedNestedKindId);
	MojTestErrCheck(err);
	err = testInsertLgNestedObj(db, MojPerfLgNestedKindId);
	MojTestErrCheck(err);
	err = testInsertMedArrayObj(db, MojPerfMedArrayKindId);
	MojTestErrCheck(err);
	err = testInsertLgArrayObj(db, MojPerfLgArrayKindId);
	MojTestErrCheck(err);

	// insert objects with two indices
	err = testInsertSmallObj(db, MojPerfSmKind2Id);
	MojTestErrCheck(err);
	err = testInsertMedObj(db, MojPerfMedKind2Id);
	MojTestErrCheck(err);
	err = testInsertLgObj(db, MojPerfLgKind2Id);
	MojTestErrCheck(err);
	err = testInsertMedNestedObj(db, MojPerfMedNestedKind2Id);
	MojTestErrCheck(err);
	err = testInsertLgNestedObj(db, MojPerfLgNestedKind2Id);
	MojTestErrCheck(err);
	err = testInsertMedArrayObj(db, MojPerfMedArrayKind2Id);
	MojTestErrCheck(err);
	err = testInsertLgArrayObj(db, MojPerfLgArrayKind2Id);
	MojTestErrCheck(err);

	// batch insert with one index
	err = testBatchInsertLgObj(db, MojPerfLgKindId);
	MojTestErrCheck(err);
	err = testBatchInsertLgNestedObj(db, MojPerfLgNestedKindId);
	MojTestErrCheck(err);
	err = testBatchInsertLgArrayObj(db, MojPerfLgArrayKindId);
	MojTestErrCheck(err);

	// batch insert with two indices
	err = testBatchInsertLgObj(db, MojPerfLgKind2Id);
	MojTestErrCheck(err);
	err = testBatchInsertLgNestedObj(db, MojPerfLgNestedKind2Id);
	MojTestErrCheck(err);
	err = testBatchInsertLgArrayObj(db, MojPerfLgArrayKind2Id);
	MojTestErrCheck(err);

	err = db.close();
	MojTestErrCheck(err);

	return MojErrNone;
}
Exemplo n.º 2
0
MojErr MojDbPerfCreateTest::testCreate()
{

	//setup the test storage engine
#ifdef MOJ_USE_BDB
	MojRefCountedPtr<MojDbStorageEngine> engine(new MojDbBerkeleyEngine());
#elif MOJ_USE_LDB
	MojRefCountedPtr<MojDbStorageEngine> engine(new MojDbLevelEngine());
#else
    MojRefCountedPtr<MojDbStorageEngine> engine;
#endif
	MojAllocCheck(engine.get());
    MojDb db;

	MojErr err = db.open(MojDbTestDir, engine.get());
	MojTestErrCheck(err);

	// time put kind
	MojTime putKindTime;
	for (int i = 0; i < numRepetitions; i++) {
		err = putKinds(db, putKindTime);
		MojTestErrCheck(err);
		err = delKinds(db);
		MojTestErrCheck(err);
	}

	MojUInt64 putKind = putKindTime.microsecs();
	err = MojPrintF("\n -------------------- \n");
	MojTestErrCheck(err);
	err = MojPrintF("   putKind took: %llu microsecs", (putKind / (numKinds * numRepetitions)));
	MojTestErrCheck(err);
	err = MojPrintF("\n\n");
	MojTestErrCheck(err);

	MojString buf;
	err = buf.format("put Kind,all %llu kinds,%llu,%llu,%llu,\n", numKinds, putKind, putKind/numRepetitions, putKind / (numKinds * numRepetitions));
	MojTestErrCheck(err);
	err = fileWrite(file, buf);
	MojTestErrCheck(err);

	// insert objects with one index
	err = testInsertSmallObj(db, MojPerfSmKindId);
	MojTestErrCheck(err);
	err = testInsertMedObj(db, MojPerfMedKindId);
	MojTestErrCheck(err);
	err = testInsertLgObj(db, MojPerfLgKindId);
	MojTestErrCheck(err);
	err = testInsertMedNestedObj(db, MojPerfMedNestedKindId);
	MojTestErrCheck(err);
	err = testInsertLgNestedObj(db, MojPerfLgNestedKindId);
	MojTestErrCheck(err);
	err = testInsertMedArrayObj(db, MojPerfMedArrayKindId);
	MojTestErrCheck(err);
	err = testInsertLgArrayObj(db, MojPerfLgArrayKindId);
	MojTestErrCheck(err);

	// insert objects with two indices
	err = testInsertSmallObj(db, MojPerfSmKind2Id);
	MojTestErrCheck(err);
	err = testInsertMedObj(db, MojPerfMedKind2Id);
	MojTestErrCheck(err);
	err = testInsertLgObj(db, MojPerfLgKind2Id);
	MojTestErrCheck(err);
	err = testInsertMedNestedObj(db, MojPerfMedNestedKind2Id);
	MojTestErrCheck(err);
	err = testInsertLgNestedObj(db, MojPerfLgNestedKind2Id);
	MojTestErrCheck(err);
	err = testInsertMedArrayObj(db, MojPerfMedArrayKind2Id);
	MojTestErrCheck(err);
	err = testInsertLgArrayObj(db, MojPerfLgArrayKind2Id);
	MojTestErrCheck(err);

	// batch insert with one index
	err = testBatchInsertLgObj(db, MojPerfLgKindId);
	MojTestErrCheck(err);
	err = testBatchInsertLgNestedObj(db, MojPerfLgNestedKindId);
	MojTestErrCheck(err);
	err = testBatchInsertLgArrayObj(db, MojPerfLgArrayKindId);
	MojTestErrCheck(err);

	// batch insert with two indices
	err = testBatchInsertLgObj(db, MojPerfLgKind2Id);
	MojTestErrCheck(err);
	err = testBatchInsertLgNestedObj(db, MojPerfLgNestedKind2Id);
	MojTestErrCheck(err);
	err = testBatchInsertLgArrayObj(db, MojPerfLgArrayKind2Id);
	MojTestErrCheck(err);

	err = db.close();
	MojTestErrCheck(err);

	return MojErrNone;
}