summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-10-18 13:34:21 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2019-10-18 13:34:21 +0100
commit496bdea259758816e624024cb485f37d867ae63d (patch)
tree4a9226b045725c1ab2ab0daade66d9d1e76fe745
parentModernize build (diff)
downloadslicer-496bdea259758816e624024cb485f37d867ae63d.tar.bz2
slicer-496bdea259758816e624024cb485f37d867ae63d.tar.xz
slicer-496bdea259758816e624024cb485f37d867ae63d.zip
Performance tweaks
Critical replace some boost functions with C ones
-rw-r--r--slicer/db/testSelect.cpp7
-rw-r--r--slicer/json/serializer.cpp2
-rw-r--r--slicer/slicer/modelParts.cpp5
-rw-r--r--slicer/test/conversions.cpp2
-rw-r--r--slicer/test/serializers.cpp19
-rw-r--r--slicer/test/streams.cpp1
6 files changed, 30 insertions, 6 deletions
diff --git a/slicer/db/testSelect.cpp b/slicer/db/testSelect.cpp
index d2c9b24..ce7821c 100644
--- a/slicer/db/testSelect.cpp
+++ b/slicer/db/testSelect.cpp
@@ -242,5 +242,12 @@ BOOST_AUTO_TEST_CASE( select_null )
BOOST_REQUIRE(!v);
}
+BOOST_AUTO_TEST_CASE( bulkSelectTest )
+{
+ auto sel = db->select(R"SQL(select s mint, cast(s as numeric(7,1)) mdouble, cast(s as text) mstring, s % 2 = 0 mbool from generate_series(1, 10000) s)SQL");
+ auto vec = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::BuiltInSeq>(sel.get());
+ BOOST_REQUIRE_EQUAL(10000, vec.size());
+}
+
BOOST_AUTO_TEST_SUITE_END();
diff --git a/slicer/json/serializer.cpp b/slicer/json/serializer.cpp
index 3a8be0a..d56a98e 100644
--- a/slicer/json/serializer.cpp
+++ b/slicer/json/serializer.cpp
@@ -1,7 +1,7 @@
#include "serializer.h"
#include <slicer/metadata.h>
#include <jsonpp.h>
-#include <boost/lexical_cast.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <functional>
#include <stdexcept>
#include <fstream>
diff --git a/slicer/slicer/modelParts.cpp b/slicer/slicer/modelParts.cpp
index e70cd61..6f68e9c 100644
--- a/slicer/slicer/modelParts.cpp
+++ b/slicer/slicer/modelParts.cpp
@@ -1,6 +1,4 @@
#include "modelParts.h"
-#include <boost/lexical_cast.hpp>
-#include <boost/algorithm/string/predicate.hpp>
namespace Slicer {
const Metadata emptyMetadata;
@@ -95,7 +93,8 @@ namespace Slicer {
bool
case_less::operator()(std::string_view && a, std::string_view && b) const
{
- return boost::ilexicographical_compare(a, b);
+ const auto cmp = strncasecmp(a.data(), b.data(), std::min(a.length(), b.length()));
+ return (cmp < 0) || (!cmp && a.length() < b.length());
}
}
diff --git a/slicer/test/conversions.cpp b/slicer/test/conversions.cpp
index ccb6a0d..9c148aa 100644
--- a/slicer/test/conversions.cpp
+++ b/slicer/test/conversions.cpp
@@ -94,7 +94,7 @@ namespace Slicer {
if (s.empty()) {
return IceUtil::None;
}
- return boost::lexical_cast<Ice::Int>(s);
+ return std::stoi(s);
}
DLL_PUBLIC
diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp
index a6b6b23..9b0ef95 100644
--- a/slicer/test/serializers.cpp
+++ b/slicer/test/serializers.cpp
@@ -661,3 +661,22 @@ BOOST_AUTO_TEST_CASE( customerModelPartCounters )
BOOST_REQUIRE_EQUAL(21, TestModule::completions);
}
+BOOST_FIXTURE_TEST_SUITE(l, Slicer::case_less);
+
+BOOST_AUTO_TEST_CASE(case_less_test)
+{
+ const auto & lc { *this };
+ BOOST_CHECK(!lc("", ""));
+ BOOST_CHECK(lc("a", "b"));
+ BOOST_CHECK(lc("A", "b"));
+ BOOST_CHECK(lc("Aa", "b"));
+ BOOST_CHECK(lc("AA", "b"));
+ BOOST_CHECK(lc("aA", "b"));
+ BOOST_CHECK(lc("A", "B"));
+ BOOST_CHECK(lc("Aa", "Bb"));
+ BOOST_CHECK(lc("AA", "bB"));
+ BOOST_CHECK(lc("aA", "BB"));
+}
+
+BOOST_AUTO_TEST_SUITE_END();
+
diff --git a/slicer/test/streams.cpp b/slicer/test/streams.cpp
index e22506e..3ea4933 100644
--- a/slicer/test/streams.cpp
+++ b/slicer/test/streams.cpp
@@ -1,7 +1,6 @@
#define BOOST_TEST_MODULE streams
#include <boost/test/unit_test.hpp>
-#include <boost/lexical_cast.hpp>
#include <xml/serializer.h>
#include <json/serializer.h>
#include <slicer.h>