geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bben...@apache.org
Subject [geode-native] branch develop updated: GEODE-6957: Add simple logging benchmarks (#502)
Date Mon, 15 Jul 2019 21:32:29 GMT
This is an automated email from the ASF dual-hosted git repository.

bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new 91d2975  GEODE-6957: Add simple logging benchmarks (#502)
91d2975 is described below

commit 91d2975cc811ea2824c526e1b42b559c99bf6d71
Author: Blake Bender <bbender@pivotal.io>
AuthorDate: Mon Jul 15 14:32:24 2019 -0700

    GEODE-6957: Add simple logging benchmarks (#502)
    
    * Log strings of various lengths and measure
    * Measure file logging as well as console logging
    
    This will be used to establish a baseline measurement we can compare against any future
logging changes
    
    Co-authored-by: Matthew Reddington <mreddington@pivotal.io>
---
 cppcache/benchmark/CMakeLists.txt     |   1 +
 cppcache/benchmark/GeodeLoggingBM.cpp | 122 ++++++++++++++++++++++++++++++++++
 cppcache/src/CacheXmlParser.cpp       |   5 +-
 3 files changed, 125 insertions(+), 3 deletions(-)

diff --git a/cppcache/benchmark/CMakeLists.txt b/cppcache/benchmark/CMakeLists.txt
index 5461abe..146424e 100644
--- a/cppcache/benchmark/CMakeLists.txt
+++ b/cppcache/benchmark/CMakeLists.txt
@@ -16,6 +16,7 @@
 add_executable(cpp-benchmark
   main.cpp
   GeodeHashBM.cpp
+  GeodeLoggingBM.cpp
   )
 
 target_link_libraries(cpp-benchmark
diff --git a/cppcache/benchmark/GeodeLoggingBM.cpp b/cppcache/benchmark/GeodeLoggingBM.cpp
new file mode 100644
index 0000000..ac49e31
--- /dev/null
+++ b/cppcache/benchmark/GeodeLoggingBM.cpp
@@ -0,0 +1,122 @@
+/*
+ * 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 <benchmark/benchmark.h>
+
+#include <array>
+
+#include <boost/filesystem.hpp>
+
+#include <geode/CacheableString.hpp>
+
+#include "geode/util/LogLevel.hpp"
+#include "util/Log.hpp"
+#include "util/string.hpp"
+
+using apache::geode::client::Log;
+using apache::geode::client::LogLevel;
+using apache::geode::client::to_utf16;
+using apache::geode::client::to_utf8;
+using apache::geode::client::internal::geode_hash;
+
+const int STRING_ARRAY_LENGTH = 3;
+
+int g_iteration = 0;
+
+std::array<const char*, STRING_ARRAY_LENGTH> logStrings{
+    "Short test string", "Slightly longer test string",
+    "Very long string: "
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"};
+
+void GeodeLogStrings(benchmark::State& state) {
+  int index = g_iteration++ % STRING_ARRAY_LENGTH;
+
+  for (auto _ : state) {
+    Log::debug(logStrings[index]);
+  }
+}
+
+void GeodeLogInts(benchmark::State& state) {
+  std::string intString(std::to_string(g_iteration++));
+  for (auto _ : state) {
+    Log::debug(intString.c_str());
+  }
+}
+
+void GeodeLogCombo(benchmark::State& state) {
+  g_iteration++;
+  std::string comboString = std::string(logStrings[g_iteration % 3]) + " " +
+                            std::to_string(g_iteration);
+  for (auto _ : state) {
+    Log::debug(comboString.c_str());
+  }
+}
+
+template <void T(benchmark::State&)>
+void GeodeLogToConsole(benchmark::State& state) {
+  Log::setLogLevel(LogLevel::All);
+
+  T(state);
+
+  Log::close();
+}
+
+template <void T(benchmark::State&)>
+void GeodeLogToFile(benchmark::State& state) {
+  boost::filesystem::path sourcePath(__FILE__);
+  auto filename = std::string("geode_native_") + sourcePath.stem().string() +
+                  std::to_string(__LINE__) + ".log";
+  boost::filesystem::path logPath(filename);
+
+  Log::init(LogLevel::All, filename.c_str());
+
+  T(state);
+
+  Log::close();
+
+  if (boost::filesystem::exists(logPath)) {
+    boost::filesystem::remove(logPath);
+  }
+}
+
+auto LogStringsToConsole = GeodeLogToConsole<GeodeLogStrings>;
+auto LogIntsToConsole = GeodeLogToConsole<GeodeLogInts>;
+auto LogComboToConsole = GeodeLogToConsole<GeodeLogCombo>;
+
+auto LogStringsToFile = GeodeLogToFile<GeodeLogStrings>;
+auto LogIntsToFile = GeodeLogToFile<GeodeLogInts>;
+auto LogComboToFile = GeodeLogToFile<GeodeLogCombo>;
+
+BENCHMARK(LogStringsToConsole)->Range(8, 8 << 10);
+BENCHMARK(LogIntsToConsole)->Range(8, 8 << 10);
+BENCHMARK(LogComboToConsole)->Range(8, 8 << 10);
+BENCHMARK(LogStringsToFile)->Range(8, 8 << 10);
+BENCHMARK(LogIntsToFile)->Range(8, 8 << 10);
+BENCHMARK(LogComboToFile)->Range(8, 8 << 10);
diff --git a/cppcache/src/CacheXmlParser.cpp b/cppcache/src/CacheXmlParser.cpp
index 8320171..ac9892d 100644
--- a/cppcache/src/CacheXmlParser.cpp
+++ b/cppcache/src/CacheXmlParser.cpp
@@ -361,12 +361,11 @@ void CacheXmlParser::endElement(const XMLCh *const,
 }
 
 void CacheXmlParser::fatalError(const xercesc::SAXParseException &exception) {
-  using namespace xercesc;
-  char *message = XMLString::transcode(exception.getMessage());
+  char *message = xercesc::XMLString::transcode(exception.getMessage());
   LOGDEBUG("Fatal Error: \"%s\" at line: %ulld", message,
            exception.getLineNumber());
   auto ex = CacheXmlException(message);
-  XMLString::release(&message);
+  xercesc::XMLString::release(&message);
   throw ex;
 }
 


Mime
View raw message