Skip to content

Commit

Permalink
Log timing of the FindOversizeCross test
Browse files Browse the repository at this point in the history
* Allows some analysis of offer operations
  • Loading branch information
ximinez committed Aug 13, 2024
1 parent c19a88f commit 9b32450
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/xrpl/protocol/Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ std::size_t constexpr unfundedOfferRemoveLimit = 1000;
std::size_t constexpr expiredOfferRemoveLimit = 256;

/** The maximum number of metadata entries allowed in one transaction */
std::size_t constexpr oversizeMetaDataCap = 5200;
std::size_t constexpr oversizeMetaDataCap = 1000; // 5200;

/** The maximum number of entries per directory page */
std::size_t constexpr dirNodeMaxEntries = 32;
Expand Down
39 changes: 37 additions & 2 deletions src/test/app/OversizeMeta_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <test/jtx.h>
#include <xrpl/beast/unit_test.h>
#include <algorithm>
#include <chrono>

namespace ripple {
namespace test {
Expand Down Expand Up @@ -162,6 +163,7 @@ class FindOversizeCross_test : public beast::unit_test::suite
oversize(std::size_t n)
{
using namespace jtx;
using clock = std::chrono::high_resolution_clock;
auto const billion = 1000000000ul;
Env env(*this);
env.disable_sigs();
Expand All @@ -170,9 +172,42 @@ class FindOversizeCross_test : public beast::unit_test::suite
env.fund(XRP(billion), gw, "alice");
env.trust(USD(billion), "alice");
env(pay(gw, "alice", USD(billion)));
createOffers(env, USD, n);
{
auto const start = clock::now();
createOffers(env, USD, n);
std::chrono::nanoseconds duration = clock::now() - start;
auto const count = duration.count();

std::cout << "Created " << n
<< " offers (including ledger close) in " << count
<< "ns. Average time per offer: " << (count / n)
<< "ns\n";
}
env(pay("alice", gw, USD(billion)));
env(offer("alice", USD(1), XRP(1)), ter(std::ignore));
{
auto const start = clock::now();
env(offer("alice", USD(1), XRP(1)), ter(std::ignore));
std::chrono::nanoseconds duration = clock::now() - start;
auto const count = duration.count();

auto const meta = env.meta();
auto const affected =
meta->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
std::size_t numDeleted = 0;
for (auto const& obj : affected)
{
if (obj.isMember(sfDeletedNode.fieldName))
++numDeleted;
}

std::cout << "Offer crossing result: " << transToken(env.ter())
<< ". Touched " << affected.size()
<< " ledger objects, and deleted " << numDeleted << " in "
<< count << "ns. Average time per deleted offer: "
<< (numDeleted > 0 ? to_string(count / numDeleted) : "-")
<< "ns\n";
std::cout << "\n";
}
return env.ter() == tecOVERSIZE;
}

Expand Down

0 comments on commit 9b32450

Please sign in to comment.