aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-07-08 15:00:58 +0200
committerMauro Sardara <msardara@cisco.com>2019-07-08 16:45:04 +0200
commit63422dfdcb1cd6827e76440cc147c9eac415952a (patch)
treeaeafaffb0e1f7a68c823611609e21983f51f5d0e /utils/src
parent87cd4b4d22a08f1b56cd067770a29bcb05ebb845 (diff)
[HICN-242] Perform only one allocation for the whole buffer passed to produce()
Change-Id: Ib4628d0a7711e2d7175b3dbb5c152dd22616ff32 Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'utils/src')
-rw-r--r--utils/src/hiperf.cc18
1 files changed, 13 insertions, 5 deletions
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<const uint8_t *>(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<utils::Microseconds>(t1 - t0).count()
+ << " us)" << std::endl;
}
std::shared_ptr<utils::Identity> setProducerIdentity(