cpp51example_main.cpp
TBD: Update GenDefines.txt with a $DESCRIPTION for this example. This example needs a compiled schema, BenchmarkDB.sdl.
/*
* Raima db benchmarks with google benchmark framework
*/
#include <stdio.h>
#include "rdm.h"
#include "sw.h"
#include "BenchmarkDB_cat.h"
#include "BenchmarkDB_structs.h"
#if defined(RDM_EASY_PROFILER)
#include "easy/profiler.h"
#endif
#if defined(RDM_EASY_PROFILER)
static constexpr uint32_t numIterations{20};
#else
static constexpr uint32_t numIterations{1000};
#endif
static void inline checkRdmRc (
RDM_RETCODE rc,
RDM_RETCODE rc_expected,
const char *func,
uint32_t line)
{
if (rc != rc_expected)
{
std::cerr << func << ":" << line << " expected "
<< rdm_retcodeGetName (rc) << " ("
std::abort ();
}
}
// Those checks have no significant impact on benchmarks (and also would be
// there similarly in practice), still can use second define to completely
// remove when debugging is finished.
#define CHECK_RC(rc) checkRdmRc (rc, sOKAY, __func__, __LINE__)
#define CHECK_EXPECTED_RC(rc, rc_expected) \
checkRdmRc (rc, rc_expected, __func__, __LINE__)
// #define CHECK_RC(rc) (void)rc
// Taken from
// https://preshing.com/20121224/how-to-generate-a-sequence-of-unique-random-integers/
// (because generating unique pseudo randoms with std:: is harder)
unsigned int m_index;
unsigned int m_intermediateOffset;
static unsigned int permuteQPR (unsigned int x)
{
static const unsigned int prime = 4294967291u;
if (x >= prime)
return x; // The 5 integers out of range are mapped to themselves.
unsigned int residue = ((unsigned long long) x * x) % prime;
return (x <= prime / 2) ? residue : prime - residue;
}
void RandomSequenceOfUnique (unsigned int seedBase, unsigned int seedOffset)
{
m_index = permuteQPR (permuteQPR (seedBase) + 0x682f0161);
m_intermediateOffset = permuteQPR (permuteQPR (seedOffset) + 0x46790905);
}
unsigned int next ()
{
return permuteQPR (
(permuteQPR (m_index++) + m_intermediateOffset) ^ 0x5bf03635);
}
RDM_TFS m_tfs;
RDM_DB m_c_db;
#define db_size (64 * 1024 * 1024)
uint8_t m_db_memory[db_size];
void BenchmarkDBInit ()
{
RDM_RETCODE rc;
rc = eFAIL;
{
rc = rdm_tfsInitialize (m_tfs);
if (rc == sOKAY)
{
rc = rdm_tfsAllocDatabase (m_tfs, &m_c_db);
if (rc == sOKAY)
{
rc = rdm_dbSetOptions (
m_c_db, "storage=inmemory_volatile;cache_size=100");
if (rc == sOKAY)
{
rc = rdm_dbLoadCatalog (m_c_db, BenchmarkDB_cat);
if (rc == sOKAY)
{
rc = rdm_dbOpen (
}
}
if (rc != sOKAY)
{
rdm_dbFree (m_c_db);
m_c_db = NULL;
}
}
}
if (rc != sOKAY)
{
rdm_tfsFree (m_tfs);
m_tfs = NULL;
}
}
CHECK_RC (rc);
}
void BenchmarkDBTerm ()
{
if (m_tfs)
{
if (m_c_db)
{
rdm_dbFree (m_c_db);
m_c_db = NULL;
}
rdm_tfsFree (m_tfs);
m_tfs = NULL;
}
}
void insertLinksManyLocks (const uint32_t numberOfLinks)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
Link_psd21 Link_psd21;
for (LinkID pkey = 0; pkey < numberOfLinks; pkey++)
{
CHECK_RC (rdm_dbStartUpdate (
Link_psd21.linkId = pkey;
CHECK_RC (rdm_dbInsertRow (
m_c_db, TABLE_LINK_PSD21, &Link_psd21, sizeof (Link_psd21), NULL));
CHECK_RC (rdm_dbEnd (m_c_db));
}
}
void insertLandmarksManyLocks (const uint32_t numberOfLandmarks)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
for (LinkID pkey = 0; pkey < numberOfLandmarks; pkey++)
{
Landmark landmark{pkey};
CHECK_RC (rdm_dbStartUpdate (
m_c_db, RDM_LOCK_ALL, 0, RDM_LOCK_NONE, 0, NULL));
CHECK_RC (rdm_dbInsertRow (
m_c_db, TABLE_LANDMARK, &landmark, sizeof (Landmark), NULL));
CHECK_RC (rdm_dbEnd (m_c_db));
}
}
void insertLandmarksOneLock (const uint32_t numberOfLandmarks)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
CHECK_RC (
for (LinkID pkey = 0; pkey < numberOfLandmarks; pkey++)
{
Landmark landmark{pkey};
CHECK_RC (rdm_dbInsertRow (
m_c_db, TABLE_LANDMARK, &landmark, sizeof (Landmark), NULL));
}
CHECK_RC (rdm_dbEnd (m_c_db));
}
void getLandmark (const uint64_t id, const uint32_t numberOfGets)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
Landmark landmark;
for (size_t i = 0; i < numberOfGets; i++)
{
uint64_t pkey = id;
RDM_CURSOR cursor = NULL;
m_c_db, KEY_LANDMARK_ID, &pkey, sizeof (pkey), &cursor);
if (rc == sOKAY)
{
CHECK_RC (
}
CHECK_RC (rdm_dbEnd (m_c_db));
CHECK_RC (rdm_cursorFree (cursor));
}
}
void getLanegroup (const uint64_t id, const uint32_t numberOfGets)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
LaneGroup_psd21 lgrp;
for (size_t i = 0; i < numberOfGets; i++)
{
uint64_t pkey = id;
RDM_CURSOR cursor = NULL;
CHECK_RC (rdm_dbStartRead (m_c_db, RDM_LOCK_ALL, 0, NULL));
auto rc = rdm_dbGetRowsByKeyAtKey (
m_c_db, KEY_LANEGROUP_PSD21_LANEGROUP_ID, &pkey, sizeof (pkey),
&cursor);
if (rc == sOKAY)
{
CHECK_RC (rdm_cursorReadRow (cursor, &lgrp, sizeof (lgrp), NULL));
}
CHECK_RC (rdm_dbEnd (m_c_db));
CHECK_RC (rdm_cursorFree (cursor));
}
}
void deleteLanegroup (const uint64_t id, const uint32_t numberOfDeletes)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
for (size_t i = id; i < id + numberOfDeletes; i++)
{
uint64_t pkey = i;
RDM_CURSOR cursor = NULL;
CHECK_RC (rdm_dbStartUpdate (m_c_db, RDM_LOCK_ALL, 0, NULL, 0, NULL));
auto rc = rdm_dbGetRowsByKeyAtKey (
m_c_db, KEY_LANEGROUP_PSD21_LANEGROUP_ID, &pkey, sizeof (pkey),
&cursor);
if (rc == sOKAY)
{
CHECK_RC (rdm_cursorDeleteRow (cursor));
}
CHECK_RC (rdm_dbEnd (m_c_db));
CHECK_RC (rdm_cursorFree (cursor));
}
}
void deleteLandmark (const uint64_t id, const uint32_t numberOfDeletes)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
for (size_t i = id; i < id + numberOfDeletes; i++)
{
uint64_t pkey = i;
RDM_CURSOR cursor = NULL;
CHECK_RC (rdm_dbStartUpdate (m_c_db, RDM_LOCK_ALL, 0, NULL, 0, NULL));
auto rc = rdm_dbGetRowsByKeyAtKey (
m_c_db, KEY_LANDMARK_ID, &pkey, sizeof (pkey),
&cursor);
if (rc == sOKAY)
{
CHECK_RC (rdm_cursorDeleteRow (cursor));
}
CHECK_RC (rdm_dbEnd (m_c_db));
CHECK_RC (rdm_cursorFree (cursor));
}
}
void deleteLink (const uint64_t id, const uint32_t numberOfDeletes)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
for (size_t i = id; i < id + numberOfDeletes; i++)
{
uint64_t pkey = i;
RDM_CURSOR cursor = NULL;
CHECK_RC (rdm_dbStartUpdate (m_c_db, RDM_LOCK_ALL, 0, NULL, 0, NULL));
auto rc = rdm_dbGetRowsByKeyAtKey (
m_c_db, KEY_LINK_PSD21_LINKID, &pkey, sizeof (pkey),
&cursor);
if (rc == sOKAY)
{
CHECK_RC (rdm_cursorDeleteRow (cursor));
}
else
{
CHECK_RC (rc);
}
CHECK_RC (rdm_dbEnd (m_c_db));
CHECK_RC (rdm_cursorFree (cursor));
}
}
void getLink (const uint64_t id, const uint32_t numberOfGets)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
Link_psd21 link;
for (size_t i = 0; i < numberOfGets; i++)
{
uint64_t pkey = id;
RDM_CURSOR cursor = NULL;
CHECK_RC (rdm_dbStartRead (m_c_db, RDM_LOCK_ALL, 0, NULL));
auto rc = rdm_dbGetRowsByKeyAtKey (
m_c_db, KEY_LINK_PSD21_LINKID, &pkey, sizeof (pkey), &cursor);
if (rc == sOKAY)
{
CHECK_RC (rdm_cursorReadRow (cursor, &link, sizeof (link), NULL));
}
CHECK_RC (rdm_dbEnd (m_c_db));
CHECK_RC (rdm_cursorFree (cursor));
}
}
void insert1350LinksOneTransaction (bool randomIds)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
Link_psd21 Link_psd21;
for (LinkID pkey = 0; pkey < 1350; pkey++)
{
Link_psd21.linkId = randomIds ? next () : pkey;
CHECK_RC (rdm_dbInsertRow (
m_c_db, TABLE_LINK_PSD21, &Link_psd21, sizeof (Link_psd21), NULL));
}
rdm_dbEnd (m_c_db);
}
void insertLanegroup (RDM_CPP::BENCHMARKDB::LaneGroupID id)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
Lane_psd21 lane = {0};
LaneGroup_psd21 lg = {0};
LaneGroup_Links_psd21 lgToLink = {0};
uint8_t blobData[1000]{};
CHECK_RC (
RDM_CURSOR cursor{nullptr};
lg.LaneGroup_ID = id;
lg.centerline_min_x = id;
CHECK_RC (rdm_dbInsertRow (
m_c_db, TABLE_LANEGROUP_PSD21, &lg, sizeof (lg), &cursor));
// Til here it is already 140 DMIPS?
CHECK_RC (rdm_cursorUpdateBlob (
cursor, COL_LANEGROUP_PSD21_BINARY_OVERFLOW, 0, blobData,
sizeof (blobData)));
// Also insert two lanes per lanegroup
lane.LocalLane_ID = 1;
lane.LaneGroup_ID = id;
CHECK_RC (
rdm_dbInsertRow (m_c_db, TABLE_LANE_PSD21, &lane, sizeof (lane), NULL));
lane.LocalLane_ID = 2;
CHECK_RC (
rdm_dbInsertRow (m_c_db, TABLE_LANE_PSD21, &lane, sizeof (lane), NULL));
// Til here becomes 360 DMIPS..
// Add m-to-n ref to a link
lgToLink.LaneGroup_ID = id;
lgToLink.Link_ID =
id / 2; // Assume insert1350 WITHOUT random keys has run...
CHECK_RC (rdm_dbInsertRow (
m_c_db, TABLE_LANEGROUP_LINKS_PSD21, &lgToLink, sizeof (lgToLink),
NULL));
// And that make it 700 DMIPS.
#
CHECK_RC (rdm_cursorFree (cursor));
CHECK_RC (rdm_dbEnd (m_c_db));
}
void insertLanegroupsOneTransaction (const uint32_t number_of_lgs)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
CHECK_RC (
for (uint32_t lid = 0; lid < number_of_lgs; lid++)
{
insertLanegroup (lid);
}
CHECK_RC (rdm_dbEnd (m_c_db));
}
void insertLanegroupsManyTransactions (const uint32_t number_of_lgs)
{
#if defined(RDM_EASY_PROFILER)
EASY_FUNCTION (profiler::colors::Magenta);
#endif
for (uint32_t lid = 0; lid < number_of_lgs; lid++)
{
CHECK_RC (rdm_dbStartUpdate (
m_c_db, RDM_LOCK_ALL, 0, RDM_LOCK_NONE, 0, NULL));
insertLanegroup (lid);
CHECK_RC (rdm_dbEnd (m_c_db));
}
}
void clear (void)
{
CHECK_RC (
CHECK_RC (rdm_dbDeleteAllRowsFromDatabase (m_c_db));
CHECK_RC (rdm_dbEnd (m_c_db));
}
void BM_insert1350LinksManyLocks ()
{
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insertLinksManyLocks (1350);
sw.stop ();
}
}
static void BM_insert1350LinksOneTransaction ()
{
SW sw("insert1350LinksOneTransaction");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insert1350LinksOneTransaction (false);
sw.stop ();
}
}
static void BM_insert1350LinksOneTransactionsRandomIds ()
{
SW sw ("insert1350LinksOneTransactionsRandomIds");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insert1350LinksOneTransaction (true);
sw.stop ();
}
}
static void BM_insert2700LanegroupsOneTransaction ()
{
SW sw ("insert2700LanegroupsOneTransaction");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insertLanegroupsOneTransaction (2700);
sw.stop ();
}
}
static void BM_insert2700LanegroupsManyTransactions ()
{
SW sw("insert2700LanegroupsManyTransactions");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insertLanegroupsManyTransactions (2700);
sw.stop ();
}
}
void insertLandmarkgroup (RDM_CPP::BENCHMARKDB::LandmarkGroupID id)
{
RDM_CPP::BENCHMARKDB::LandmarkGroup_psd21 lg{id, false};
CHECK_RC (rdm_dbInsertRow (
m_c_db, RDM_CPP::BENCHMARKDB::TABLE_LANDMARKGROUP_PSD21, &lg,
sizeof (lg), nullptr));
}
void insertLandmarkgroupsOneTransaction (const uint32_t number_of_lgs)
{
CHECK_RC (
for (uint32_t lid = 0; lid < number_of_lgs; lid++)
{
insertLandmarkgroup (lid);
}
CHECK_RC (rdm_dbEnd (m_c_db));
}
void insertLandmarkgroupsManyTransactions (const uint32_t number_of_lgs)
{
for (uint32_t lid = 0; lid < number_of_lgs; lid++)
{
CHECK_RC (rdm_dbStartUpdate (
m_c_db, RDM_LOCK_ALL, 0, RDM_LOCK_NONE, 0, NULL));
insertLandmarkgroup (lid);
CHECK_RC (rdm_dbEnd (m_c_db));
}
}
static void BM_insert1000LandmarkgroupsOneTransaction ()
{
SW sw("insert1000LandmarkgroupsOneTransaction");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insertLandmarkgroupsOneTransaction (1000);
sw.stop ();
}
}
static void BM_insert1000LandmarkgroupsManyTransactions ()
{
SW sw("insert1000LandmarkgroupsManyTransactions");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insertLandmarkgroupsManyTransactions (1000);
sw.stop ();
}
}
static void fetchLinks (int numberOfFetches)
{
Link_psd21 link;
for (size_t jj = 0; jj < numberOfFetches; jj++)
{
LinkID pkey = next () % 1350;
RDM_CURSOR cursor = NULL;
CHECK_RC (rdm_dbStartRead (m_c_db, RDM_LOCK_ALL, 0, NULL));
CHECK_RC (rdm_dbGetRowsByKeyAtKey (
m_c_db, KEY_LINK_PSD21_LINKID, &pkey, sizeof (pkey), &cursor));
CHECK_RC (rdm_cursorReadRow (cursor, &link, sizeof (link), NULL));
CHECK_RC (rdm_dbEnd (m_c_db));
CHECK_RC (rdm_cursorFree (cursor));
}
}
static void BM_fetchLinks2000 ()
{
SW sw("fetchLinks2000");
clear ();
insert1350LinksOneTransaction (false);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
fetchLinks (2000);
sw.stop ();
}
}
static void BM_fetchLinks1000 ()
{
SW sw ("fetchLinks1000");
clear ();
insert1350LinksOneTransaction (false);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
fetchLinks (1000);
sw.stop ();
}
}
static void REQ_insert100Links ()
{
SW sw("insert100Links");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insertLinksManyLocks (100);
sw.stop ();
}
}
static void REQ_insert100LanegroupsOneTransaction ()
{
SW sw( "insert100LanegroupsOneTransaction");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insertLanegroupsOneTransaction (100);
sw.stop ();
}
}
static void REQ_insert100LanegroupsManyTransactions ()
{
SW sw ("insert100LanegroupsManyTransactions");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insertLanegroupsManyTransactions (100);
sw.stop ();
}
}
static void REQ_insert1000LandmarksManyLocks ()
{
SW sw("insert1000LandmarksManyLocks");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insertLandmarksManyLocks (1000);
sw.stop ();
}
}
static void REQ_insert1000LandmarksOneLock ()
{
SW sw("insert1000LandmarksOneLock");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
sw.start ();
insertLandmarksOneLock (1000);
sw.stop ();
}
}
static void REQ_get1000Landmarks ()
{
SW sw("get1000Landmarks");
clear ();
insertLandmarksOneLock (100);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
getLandmark (1, 1000);
sw.stop ();
}
}
static void REQ_get1000Lanegroups ()
{
SW sw("get1000Lanegroups");
clear ();
insertLanegroupsOneTransaction (100);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
getLanegroup (1, 1000);
sw.stop ();
}
}
static void BM_delete1000Lanegroups ()
{
SW sw("delete1000Lanegroups");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
insertLanegroupsOneTransaction (1000);
sw.start ();
deleteLanegroup (0, 1000);
sw.stop ();
}
}
static void BM_delete1000Landmarks ()
{
SW sw("delete1000Landmarks");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
insertLandmarksOneLock (1000);
sw.start ();
deleteLandmark (0, 1000);
sw.stop ();
}
}
static void BM_delete1350Links ()
{
SW sw("delete1350Links");
for (int ii = 0; ii < numIterations; ii++)
{
clear ();
insert1350LinksOneTransaction (false);
sw.start ();
deleteLink (0, 1000);
sw.stop ();
}
}
static void REQ_get1000Links ()
{
SW sw("get1000Links");
clear ();
insertLinksManyLocks (100);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
getLink (1, 1000);
sw.stop ();
}
}
template <typename T>
void doesItemExist (
const T &id,
RDM_CPP::BENCHMARKDB::BENCHMARKDB_KEYS keyId,
const uint32_t numberOfGets,
RDM_RETCODE expected,
RDM_CURSOR cursor)
{
for (size_t i = 0; i < numberOfGets; i++)
{
CHECK_RC (rdm_dbStartRead (m_c_db, RDM_LOCK_ALL, 0, NULL));
CHECK_EXPECTED_RC (
CHECK_RC (rdm_dbEnd (m_c_db));
}
}
void insertTilesOneLock (const uint32_t numberOfTiles)
{
CHECK_RC (
RDM_CPP::BENCHMARKDB::Tile_psd21 Tile_psd21{0, 0, false};
for (uint32_t pkey = 0; pkey < numberOfTiles; pkey++)
{
Tile_psd21.tileID = pkey;
CHECK_RC (rdm_dbInsertRow (
m_c_db, RDM_CPP::BENCHMARKDB::TABLE_TILE_PSD21, &Tile_psd21,
sizeof (Tile_psd21), nullptr));
}
CHECK_RC (rdm_dbEnd (m_c_db));
}
{
auto keyId{RDM_CPP::BENCHMARKDB::BENCHMARKDB_KEYS::KEY_TILE_PSD21_TILEID};
RDM_CURSOR cursor{nullptr};
CHECK_RC (rdm_dbGetRowsByKey (m_c_db, keyId, &cursor));
doesItemExist (id, keyId, 1000, expected, cursor);
CHECK_RC (rdm_cursorFree (cursor));
}
static void REQ_doesTileExistNegative ()
{
SW sw ("doesTileExistNegative");
clear ();
insertTilesOneLock (4);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
doesTileExist (1000U, sNOTFOUND);
sw.stop ();
}
}
static void REQ_doesTileExistPositive ()
{
SW sw ("doesTileExistPositive");
clear ();
insertTilesOneLock (4);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
doesTileExist (1, sOKAY);
sw.stop ();
}
}
static void doesLinkExist (
RDM_CPP::BENCHMARKDB::LinkID id,
RDM_RETCODE expected)
{
auto keyId{RDM_CPP::BENCHMARKDB::BENCHMARKDB_KEYS::KEY_LINK_PSD21_LINKID};
RDM_CURSOR cursor{nullptr};
CHECK_RC (rdm_dbGetRowsByKey (m_c_db, keyId, &cursor));
doesItemExist (id, keyId, 1000, expected, cursor);
CHECK_RC (rdm_cursorFree (cursor));
}
static void REQ_doesLinkExistNegative ()
{
SW sw ("doesLinkExistNegative");
clear ();
insert1350LinksOneTransaction (false);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
doesLinkExist (10000U, sNOTFOUND);
sw.stop ();
}
}
static void REQ_doesLinkExistPositive ()
{
SW sw ("doesLinkExistPositive");
clear ();
insert1350LinksOneTransaction (false);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
doesLinkExist (1000U, sOKAY);
sw.stop ();
}
}
static void doesLanegroupExist (
RDM_CPP::BENCHMARKDB::LaneGroupID id,
RDM_RETCODE expected)
{
auto keyId{RDM_CPP::BENCHMARKDB::BENCHMARKDB_KEYS::
KEY_LANEGROUP_PSD21_LANEGROUP_ID};
RDM_CURSOR cursor{nullptr};
CHECK_RC (rdm_dbGetRowsByKey (m_c_db, keyId, &cursor));
doesItemExist (id, keyId, 1000, expected, cursor);
CHECK_RC (rdm_cursorFree (cursor));
}
static void REQ_doesLanegroupExistNegative ()
{
SW sw ("doesLanegroupExistNegative");
clear ();
insertLanegroupsOneTransaction (1000);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
doesLanegroupExist (10000U, sNOTFOUND);
sw.stop ();
}
}
static void REQ_doesLanegroupExistPositive ()
{
SW sw ("doesLanegroupExistPositive");
clear ();
insertLanegroupsOneTransaction (1000);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
doesLanegroupExist (500U, sOKAY);
sw.stop ();
}
}
static void doesLandmarkgroupExist (
RDM_CPP::BENCHMARKDB::LandmarkGroupID id,
RDM_RETCODE expected)
{
auto keyId{RDM_CPP::BENCHMARKDB::BENCHMARKDB_KEYS::
KEY_LANDMARKGROUP_PSD21_LANDMARKGROUP_ID};
RDM_CURSOR cursor{nullptr};
CHECK_RC (rdm_dbGetRowsByKey (m_c_db, keyId, &cursor));
doesItemExist (id, keyId, 1000, expected, cursor);
CHECK_RC (rdm_cursorFree (cursor));
}
static void REQ_doesLandmarkgroupExistNegative ()
{
SW sw ("doesLandmarkgroupExistNegative");
clear ();
insertLandmarkgroupsOneTransaction (1000);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
doesLandmarkgroupExist (10000U, sNOTFOUND);
sw.stop ();
}
}
static void REQ_doesLandmarkgroupExistPositive ()
{
SW sw ("doesLandmarkgroupExistPositive");
clear ();
insertLandmarkgroupsOneTransaction (1000);
for (int ii = 0; ii < numIterations; ii++)
{
sw.start ();
doesLandmarkgroupExist (500U, sOKAY);
sw.stop ();
}
}
int main (int /*argc*/, const char ** /*argv*/)
{
#if defined(RDM_EASY_PROFILER)
EASY_PROFILER_ENABLE;
#endif
SW sws ("Test");
RandomSequenceOfUnique (4711, 815);
BenchmarkDBInit ();
sws.start ();
BM_insert1350LinksManyLocks ();
BM_insert1350LinksOneTransaction ();
BM_insert1350LinksOneTransactionsRandomIds ();
BM_insert2700LanegroupsOneTransaction ();
BM_insert2700LanegroupsManyTransactions ();
BM_insert1000LandmarkgroupsOneTransaction ();
BM_insert1000LandmarkgroupsManyTransactions ();
BM_delete1000Lanegroups ();
BM_delete1000Landmarks ();
BM_delete1350Links ();
BM_fetchLinks2000 ();
BM_fetchLinks1000 ();
REQ_insert100Links ();
REQ_insert100LanegroupsOneTransaction ();
REQ_insert100LanegroupsManyTransactions ();
REQ_insert1000LandmarksManyLocks ();
REQ_insert1000LandmarksOneLock ();
REQ_get1000Landmarks ();
REQ_get1000Lanegroups ();
REQ_get1000Links ();
REQ_doesTileExistNegative ();
REQ_doesTileExistPositive ();
REQ_doesLinkExistNegative ();
REQ_doesLinkExistPositive ();
REQ_doesLanegroupExistNegative ();
REQ_doesLanegroupExistPositive ();
REQ_doesLandmarkgroupExistNegative ();
REQ_doesLandmarkgroupExistPositive ();
sws.stop ();
BenchmarkDBTerm ();
#if defined(RDM_EASY_PROFILER)
profiler::dumpBlocksToFile ("c:\\temp\\turin.prof");
#endif
return 0;
}
const char * rdm_retcodeGetName(RDM_RETCODE retcode)
Get the mnemonic name for an error or status code.
RDM_RETCODE rdm_dbSetOptions(RDM_DB db, const char *optString)
Set RaimaDB options.
Header for the native RaimaDB Runtime API.
RDM_RETCODE rdm_dbDeleteAllRowsFromDatabase(RDM_DB db)
Remove all rows from a database.
RDM_RETCODE rdm_dbStartRead(RDM_DB db, const RDM_TABLE_ID *tableIds, uint32_t numTableIds, RDM_TRANS *pTrans)
Get read locks.
RDM_RETCODE rdm_cursorReadRow(RDM_CURSOR cursor, void *colValues, size_t bytesIn, size_t *bytesOut)
Read all columns from a row.
RDM_RETCODE rdm_cursorUpdateBlob(RDM_CURSOR cursor, RDM_COLUMN_ID columnId, uint64_t offset, const void *value, size_t bytesIn)
Update a blob column.
RDM_RETCODE rdm_dbGetRowsByKey(RDM_DB db, RDM_KEY_ID keyId, RDM_CURSOR *pCursor)
Associate an RDM_CURSOR with a row set based on a key.
RDM_RETCODE rdm_dbOpen(RDM_DB db, const char *dbNameSpec, RDM_OPEN_MODE mode)
Open an existing RaimaDB database using the specified database handle.
RDM_RETCODE rdm_dbGetRowsByKeyAtKey(RDM_DB db, RDM_KEY_ID keyId, const void *keyValue, size_t len, RDM_CURSOR *pCursor)
Associate an RDM_CURSOR with a row set that is ordered by key value and is initially positioned at th...
RDM_RETCODE rdm_tfsAllocDatabase(RDM_TFS tfs, RDM_DB *pDb)
Allocate memory for a new RaimaDB db.
RDM_RETCODE rdm_rdmAllocTFSWithMemBuf(void *pMemBuf, size_t memBufSize, RDM_TFS *phTFS)
Allocate a TFS handle with an associated memory buffer.
const char * rdm_retcodeGetDescription(RDM_RETCODE retcode)
Invoke RaimaDB error handler.
Definition: cpp50Example/sw.h:33
RDM_RETCODE rdm_dbInsertRow(RDM_DB db, RDM_TABLE_ID tableId, const void *colValues, size_t bytesIn, RDM_CURSOR *pCursor)
Insert a new row into a table at the specified rowId.
RDM_RETCODE rdm_dbStartUpdate(RDM_DB db, const RDM_TABLE_ID *writeTableIds, uint32_t numWriteTableIds, const RDM_TABLE_ID *readTableIds, uint32_t numReadTableIds, RDM_TRANS *pTrans)
Get write locks.
RDM_RETCODE rdm_dbLoadCatalog(RDM_DB db, const char *catalog)
Associate a catalog with an allocated database.