From 63422dfdcb1cd6827e76440cc147c9eac415952a Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Mon, 8 Jul 2019 15:00:58 +0200 Subject: [HICN-242] Perform only one allocation for the whole buffer passed to produce() Change-Id: Ib4628d0a7711e2d7175b3dbb5c152dd22616ff32 Signed-off-by: Mauro Sardara --- utils/src/hiperf.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'utils/src/hiperf.cc') diff --git a/utils/src/hiperf.cc b/utils/src/hiperf.cc index 3f9cffd0c..b62173be8 100644 --- a/utils/src/hiperf.cc +++ b/utils/src/hiperf.cc @@ -610,15 +610,23 @@ class HIperfServer { void produceContent(uint32_t suffix) { core::Name name = configuration_.name.getName(); - std::string content(configuration_.download_size, '?'); + auto b = utils::MemBuf::create(configuration_.download_size); + std::memset(b->writableData(), '?', configuration_.download_size); + b->append(configuration_.download_size); uint32_t total; + utils::TimePoint t0 = utils::SteadyClock::now(); + total = producer_socket_->produce( - name, reinterpret_cast(content.data()), content.size(), - !configuration_.multiphase_produce_, suffix); + name, std::move(b), !configuration_.multiphase_produce_, suffix); - std::cout << "Written " << total << "pieces of data in output buffer" - << std::endl; + utils::TimePoint t1 = utils::SteadyClock::now(); + + std::cout + << "Written " << total + << " data packets in output buffer (Segmentation time: " + << std::chrono::duration_cast(t1 - t0).count() + << " us)" << std::endl; } std::shared_ptr setProducerIdentity( -- cgit 1.2.3-korg