Skip to content

Commit

Permalink
Dear Qt, I love you but ...
Browse files Browse the repository at this point in the history
... you are too slow and QJson API is so ugly.

Now using this wonderful json lib:
https://github.com/nlohmann/json

Results in release mode (QJson tests are not shown but
QJson was even slower than string concat).

PASS   : TestQgsJsonUtils::testExportAttributesJson(Use json)
RESULT : TestQgsJsonUtils::testExportAttributesJson():"Use json":
     0.0022 msecs per iteration (total: 75, iterations: 32768)
PASS   : TestQgsJsonUtils::testExportAttributesJson(Use old string concat)
RESULT : TestQgsJsonUtils::testExportAttributesJson():"Use old string concat":
     0.0032 msecs per iteration (total: 54, iterations: 16384)
PASS   : TestQgsJsonUtils::testExportFeatureJson(Use json)
RESULT : TestQgsJsonUtils::testExportFeatureJson():"Use json":
     0.011 msecs per iteration (total: 96, iterations: 8192)
PASS   : TestQgsJsonUtils::testExportFeatureJson(Use old string concat)
RESULT : TestQgsJsonUtils::testExportFeatureJson():"Use old string concat":
     0.015 msecs per iteration (total: 64, iterations: 4096)
PASS   : TestQgsJsonUtils::testExportGeomToJson(Use json)
RESULT : TestQgsJsonUtils::testExportGeomToJson():"Use json":
     0.76 msecs per iteration (total: 98, iterations: 128)
PASS   : TestQgsJsonUtils::testExportGeomToJson(Use old string concat)
RESULT : TestQgsJsonUtils::testExportGeomToJson():"Use old string concat":
     0.85 msecs per iteration (total: 55, iterations: 64)
PASS   : TestQgsJsonUtils::cleanupTestCase()
  • Loading branch information
elpaso committed Apr 18, 2019
1 parent 103981d commit 6371151
Show file tree
Hide file tree
Showing 116 changed files with 21,058 additions and 213 deletions.
49 changes: 49 additions & 0 deletions external/nlohmann/adl_serializer.hpp
@@ -0,0 +1,49 @@
#pragma once

#include <utility>

#include <nlohmann/detail/conversions/from_json.hpp>
#include <nlohmann/detail/conversions/to_json.hpp>

namespace nlohmann
{

template<typename, typename>
struct adl_serializer
{
/*!
@brief convert a JSON value to any value type
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).
@param[in] j JSON value to read from
@param[in,out] val value to write to
*/
template<typename BasicJsonType, typename ValueType>
static auto from_json(BasicJsonType&& j, ValueType& val) noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
{
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
}

/*!
@brief convert any value type to a JSON value
This function is usually called by the constructors of the @ref basic_json
class.
@param[in,out] j JSON value to write to
@param[in] val value to read from
*/
template <typename BasicJsonType, typename ValueType>
static auto to_json(BasicJsonType& j, ValueType&& val) noexcept(
noexcept(::nlohmann::to_json(j, std::forward<ValueType>(val))))
-> decltype(::nlohmann::to_json(j, std::forward<ValueType>(val)), void())
{
::nlohmann::to_json(j, std::forward<ValueType>(val));
}
};

} // namespace nlohmann

0 comments on commit 6371151

Please sign in to comment.