You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jd...@apache.org on 2021/04/19 20:32:42 UTC
[qpid-proton] branch main updated: PROTON-2321 Add benchmark for
pn_data_t initialization from PROTON-2229 (#286)
This is an automated email from the ASF dual-hosted git repository.
jdanek pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/main by this push:
new c90a881 PROTON-2321 Add benchmark for pn_data_t initialization from PROTON-2229 (#286)
c90a881 is described below
commit c90a881af16e643128795353df92c2c1835ead81
Author: Jiri Daněk <jd...@redhat.com>
AuthorDate: Mon Apr 19 22:32:32 2021 +0200
PROTON-2321 Add benchmark for pn_data_t initialization from PROTON-2229 (#286)
---
c/benchmarks/CMakeLists.txt | 7 ++++-
c/benchmarks/message-encoding.cpp | 57 +++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/c/benchmarks/CMakeLists.txt b/c/benchmarks/CMakeLists.txt
index e2c2a62..e3d244e 100644
--- a/c/benchmarks/CMakeLists.txt
+++ b/c/benchmarks/CMakeLists.txt
@@ -27,7 +27,12 @@ find_package(benchmark REQUIRED)
get_source_file_property(COMPILE_FLAGS benchmarks_main.cpp current_compile_flags)
set_source_files_properties(benchmarks_main.cpp PROPERTIES COMPILE_FLAGS "${current_compile_flags} -Wno-pedantic")
-add_executable(c-benchmarks benchmarks_main.cpp connection-driver.cpp message-encoding_list.cpp message-encoding_map.cpp)
+add_executable(c-benchmarks benchmarks_main.cpp
+ connection-driver.cpp
+ message-encoding.cpp
+ message-encoding_list.cpp
+ message-encoding_map.cpp
+)
target_link_libraries(c-benchmarks benchmark pthread qpid-proton)
add_test(NAME c-benchmarks COMMAND c-benchmarks)
diff --git a/c/benchmarks/message-encoding.cpp b/c/benchmarks/message-encoding.cpp
new file mode 100644
index 0000000..685a10b
--- /dev/null
+++ b/c/benchmarks/message-encoding.cpp
@@ -0,0 +1,57 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "proton/message.h"
+
+#include <benchmark/benchmark.h>
+#include <core/data.h>
+#include <proton/netaddr.h>
+
+#include <cstdlib>
+#include <cstring>
+
+/** Initialize message, don't decode?
+ * Issues:
+ * PROTON-2229 pn_data_t initialization lead to low performance
+ */
+static void BM_Encode10MbMessage(benchmark::State &state) {
+ const size_t size = 10 * 1024 * 1024;
+ char *payload = static_cast<char *>(malloc(size));
+ pn_bytes_t bytes = pn_bytes(size, payload);
+
+ for (auto _ : state) {
+ pn_message_t *message = pn_message();
+ pn_data_t *body = pn_message_body(message);
+ for (size_t i = 0; i < state.range(0); i++) {
+ pn_data_put_binary(body, bytes);
+ }
+
+ pn_message_free(message);
+ }
+
+ free(payload);
+}
+
+BENCHMARK(BM_Encode10MbMessage)
+ ->Arg(1)
+ ->Arg(2)
+ ->ArgName("put_binary count")
+ ->Unit(benchmark::kMillisecond);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org