Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed getsize call, commented ffi benchmark #377

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ namespace Platform::Data::Doublets::Benchmarks
{
using TLinkAddress = std::uint64_t;

static void BM_CreateMillionPointsFfi(benchmark::State& state)
{
using namespace Platform::Memory;
using namespace Platform::Data::Doublets::Ffi;
for (auto _ : state)
{
std::string memoryFilePath{ std::tmpnam(nullptr) };
Expects(!Collections::IsWhiteSpace(memoryFilePath));
try
{
Links<LinksOptions<TLinkAddress>> ffiStorage{memoryFilePath};
for (std::size_t i = 0; i < state.range(0); ++i)
{
CreatePoint(ffiStorage);
}
}
catch (...)
{
std::remove(memoryFilePath.c_str());
throw;
}
std::remove(memoryFilePath.c_str());
}
}
// static void BM_CreateMillionPointsFfi(benchmark::State& state)
// {
// using namespace Platform::Memory;
// using namespace Platform::Data::Doublets::Ffi;
// for (auto _ : state)
// {
// std::string memoryFilePath{ std::tmpnam(nullptr) };
// Expects(!Collections::IsWhiteSpace(memoryFilePath));
// try
// {
// Links<LinksOptions<TLinkAddress>> ffiStorage{memoryFilePath};
// for (std::size_t i = 0; i < state.range(0); ++i)
// {
// CreatePoint(ffiStorage);
// }
// }
// catch (...)
// {
// std::remove(memoryFilePath.c_str());
// throw;
// }
// std::remove(memoryFilePath.c_str());
// }
// }

static void BM_CreateMillionPointsUnitedMemory(benchmark::State& state)
{
Expand Down Expand Up @@ -78,7 +78,7 @@ namespace Platform::Data::Doublets::Benchmarks
}
}

BENCHMARK(BM_CreateMillionPointsFfi)->Arg(1000000);
//BENCHMARK(BM_CreateMillionPointsFfi)->Arg(1000000);
BENCHMARK(BM_CreateMillionPointsUnitedMemory)->Arg(1000000);
BENCHMARK(BM_CreateMillionPointsSplitMemory)->Arg(1000000);
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
public: LinkAddressType operator[](LinkAddressType index)
{
auto root = GetTreeRoot();
if (index >= GetSize(root))
if (index >= this->object().GetSize(root))
{
return 0;
}
Expand Down Expand Up @@ -124,7 +124,7 @@
public: LinkAddressType CountUsages(LinkAddressType link)
{
auto root = this->GetTreeRoot();
auto total = this->GetSize(root);
auto total = this->object().GetSize(root);
auto totalRightIgnore = 0;
while (root != 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
using Polymorph<TSelf>::object;
using LinksOptionsType = TLinksOptions;
static constexpr auto Constants = LinksOptionsType::Constants;
using LinkAddressType = typename LinksOptionsType::LinkAddressType;
using LinkAddressType = typename LinksOptionsType::LinkAddressType;
using LinkType = typename LinksOptionsType::LinkType;
using WriteHandlerType = typename LinksOptionsType::WriteHandlerType;
using ReadHandlerType = typename LinksOptionsType::ReadHandlerType;
public: static constexpr LinkAddressType Break = Constants.Break;
public: static constexpr LinkAddressType Continue = Constants.Continue;
public: std::byte* LinksDataParts;
public: std::byte* LinksIndexParts;
public: std::byte* Header;
static constexpr LinkAddressType Break = Constants.Break;
static constexpr LinkAddressType Continue = Constants.Continue;
std::byte* LinksDataParts;
std::byte* LinksIndexParts;
std::byte* Header;

public: ExternalLinksSizeBalancedTreeMethodsBase(std::byte* linksDataParts, std::byte* linksIndexParts, std::byte* header)
{
Expand All @@ -25,50 +25,50 @@
}

public: LinkAddressType GetTreeRoot()
{
return this->object().GetTreeRoot();
};
{
return this->object().GetTreeRoot();
};

public: LinkAddressType GetBasePartValue(LinkAddressType link)
{
return this->object().GetBasePartValue(link);
};
{
return this->object().GetBasePartValue(link);
};

public: bool FirstIsToTheRightOfSecond(LinkAddressType source, LinkAddressType target, LinkAddressType rootSource, LinkAddressType rootTarget)
{
return this->object().FirstIsToTheRightOfSecond(source, target, rootSource, rootTarget);
};
{
return this->object().FirstIsToTheRightOfSecond(source, target, rootSource, rootTarget);
};

public: bool FirstIsToTheLeftOfSecond(LinkAddressType source, LinkAddressType target, LinkAddressType rootSource, LinkAddressType rootTarget)
{
return this->object().FirstIsToTheLeftOfSecond(source, target, rootSource, rootTarget);
};
{
return this->object().FirstIsToTheLeftOfSecond(source, target, rootSource, rootTarget);
};

public: auto&& GetHeaderReference() const
{
return *reinterpret_cast<LinksHeader<LinkAddressType>*>(Header);
}

public: const RawLinkDataPart<LinkAddressType>& GetLinkDataPartReference(LinkAddressType link) const
public: const RawLinkDataPart<LinkAddressType>& GetLinkDataPartReference(LinkAddressType link) const
{
return *reinterpret_cast<RawLinkDataPart<LinkAddressType>*>(LinksDataParts + (RawLinkDataPart<LinkAddressType>::SizeInBytes * (link)));
}

public: RawLinkDataPart<LinkAddressType>& GetLinkDataPartReference(LinkAddressType link)
{
return *reinterpret_cast<RawLinkDataPart<LinkAddressType>*>(LinksDataParts + (RawLinkDataPart<LinkAddressType>::SizeInBytes * (link)));
}
{
return *reinterpret_cast<RawLinkDataPart<LinkAddressType>*>(LinksDataParts + (RawLinkDataPart<LinkAddressType>::SizeInBytes * (link)));
}

public: const RawLinkIndexPart<LinkAddressType>& GetLinkIndexPartReference(LinkAddressType link) const
{
return *reinterpret_cast<RawLinkIndexPart<LinkAddressType>*>(LinksIndexParts + (RawLinkIndexPart<LinkAddressType>::SizeInBytes * (link)));
}
{
return *reinterpret_cast<RawLinkIndexPart<LinkAddressType>*>(LinksIndexParts + (RawLinkIndexPart<LinkAddressType>::SizeInBytes * (link)));
}


public: RawLinkIndexPart<LinkAddressType>& GetLinkIndexPartReference(LinkAddressType link)
{
return *reinterpret_cast<RawLinkIndexPart<LinkAddressType>*>(LinksIndexParts + (RawLinkIndexPart<LinkAddressType>::SizeInBytes * (link)));
}
{
return *reinterpret_cast<RawLinkIndexPart<LinkAddressType>*>(LinksIndexParts + (RawLinkIndexPart<LinkAddressType>::SizeInBytes * (link)));
}

public: auto GetLinkValues(LinkAddressType linkIndex)
{
Expand All @@ -93,7 +93,7 @@
public: LinkAddressType operator[](LinkAddressType index)
{
auto root = GetTreeRoot();
if ((index >= GetSize(root)))
if ((index >= this->object().GetSize(root)))
{
return 0;
}
Expand Down Expand Up @@ -144,7 +144,7 @@
public: LinkAddressType CountUsages(LinkAddressType link)
{
auto root = this->GetTreeRoot();
auto total = this->GetSize(root);
auto total = this->object().GetSize(root);
auto totalRightIgnore = 0;
while (root != 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
auto operator[](std::size_t index)
{
auto root = GetTreeRoot();
if (index >= GetSize(root))
if (index >= this->object.GetSize(root))
{
return 0;
}
Expand Down Expand Up @@ -108,7 +108,7 @@
public: LinkAddressType CountUsages(LinkAddressType linkAddress)
{
auto root = this->GetTreeRoot();
auto total = this->GetSize(root);
auto total = this->object().GetSize(root);
auto totalRightIgnore = 0;
while (root != 0)
{
Expand Down