Skip to content
Permalink
Browse files

Dear Qt, I love you but ...

... 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 63711510b6831242fd3bb02b6b37204a1204b316
Showing with 21,058 additions and 213 deletions.
  1. +49 −0 external/nlohmann/adl_serializer.hpp
  2. +370 −0 external/nlohmann/detail/conversions/from_json.hpp
  3. +1,097 −0 external/nlohmann/detail/conversions/to_chars.hpp
  4. +344 −0 external/nlohmann/detail/conversions/to_json.hpp
  5. +349 −0 external/nlohmann/detail/exceptions.hpp
  6. +1,986 −0 external/nlohmann/detail/input/binary_reader.hpp
  7. +439 −0 external/nlohmann/detail/input/input_adapters.hpp
  8. +700 −0 external/nlohmann/detail/input/json_sax.hpp
  9. +1,504 −0 external/nlohmann/detail/input/lexer.hpp
  10. +496 −0 external/nlohmann/detail/input/parser.hpp
  11. +27 −0 external/nlohmann/detail/input/position_t.hpp
  12. +25 −0 external/nlohmann/detail/iterators/internal_iterator.hpp
  13. +613 −0 external/nlohmann/detail/iterators/iter_impl.hpp
  14. +170 −0 external/nlohmann/detail/iterators/iteration_proxy.hpp
  15. +49 −0 external/nlohmann/detail/iterators/iterator_traits.hpp
  16. +119 −0 external/nlohmann/detail/iterators/json_reverse_iterator.hpp
  17. +120 −0 external/nlohmann/detail/iterators/primitive_iterator.hpp
  18. +939 −0 external/nlohmann/detail/json_pointer.hpp
  19. +69 −0 external/nlohmann/detail/json_ref.hpp
  20. +151 −0 external/nlohmann/detail/macro_scope.hpp
  21. +23 −0 external/nlohmann/detail/macro_unscope.hpp
  22. +63 −0 external/nlohmann/detail/meta/cpp_future.hpp
  23. +58 −0 external/nlohmann/detail/meta/detected.hpp
  24. +142 −0 external/nlohmann/detail/meta/is_sax.hpp
  25. +348 −0 external/nlohmann/detail/meta/type_traits.hpp
  26. +13 −0 external/nlohmann/detail/meta/void_t.hpp
  27. +1,335 −0 external/nlohmann/detail/output/binary_writer.hpp
  28. +119 −0 external/nlohmann/detail/output/output_adapters.hpp
  29. +840 −0 external/nlohmann/detail/output/serializer.hpp
  30. +77 −0 external/nlohmann/detail/value_t.hpp
  31. +8,053 −0 external/nlohmann/json.hpp
  32. +64 −0 external/nlohmann/json_fwd.hpp
  33. +1 −0 python/CMakeLists.txt
  34. +2 −15 python/core/auto_generated/geometry/qgsabstractgeometry.sip.in
  35. +0 −2 python/core/auto_generated/geometry/qgscircularstring.sip.in
  36. +0 −2 python/core/auto_generated/geometry/qgscompoundcurve.sip.in
  37. +0 −2 python/core/auto_generated/geometry/qgscurvepolygon.sip.in
  38. +1 −7 python/core/auto_generated/geometry/qgsgeometry.sip.in
  39. +0 −2 python/core/auto_generated/geometry/qgsgeometrycollection.sip.in
  40. +0 −2 python/core/auto_generated/geometry/qgslinestring.sip.in
  41. +0 −2 python/core/auto_generated/geometry/qgsmulticurve.sip.in
  42. +0 −2 python/core/auto_generated/geometry/qgsmultilinestring.sip.in
  43. +0 −2 python/core/auto_generated/geometry/qgsmultipoint.sip.in
  44. +0 −2 python/core/auto_generated/geometry/qgsmultipolygon.sip.in
  45. +0 −2 python/core/auto_generated/geometry/qgsmultisurface.sip.in
  46. +0 −2 python/core/auto_generated/geometry/qgspoint.sip.in
  47. +5 −29 python/core/auto_generated/qgsjsonutils.sip.in
  48. +1 −0 src/analysis/CMakeLists.txt
  49. +2 −0 src/app/CMakeLists.txt
  50. +3 −0 src/core/CMakeLists.txt
  51. +9 −2 src/core/geometry/qgsabstractgeometry.h
  52. +2 −1 src/core/geometry/qgscircularstring.cpp
  53. +1 −1 src/core/geometry/qgscircularstring.h
  54. +2 −1 src/core/geometry/qgscompoundcurve.cpp
  55. +1 −1 src/core/geometry/qgscompoundcurve.h
  56. +8 −6 src/core/geometry/qgscurvepolygon.cpp
  57. +1 −1 src/core/geometry/qgscurvepolygon.h
  58. +5 −2 src/core/geometry/qgsgeometry.cpp
  59. +8 −3 src/core/geometry/qgsgeometry.h
  60. +6 −5 src/core/geometry/qgsgeometrycollection.cpp
  61. +1 −1 src/core/geometry/qgsgeometrycollection.h
  62. +19 −0 src/core/geometry/qgsgeometryutils.cpp
  63. +1 −0 src/core/geometry/qgsgeometryutils.h
  64. +4 −3 src/core/geometry/qgslinestring.cpp
  65. +1 −1 src/core/geometry/qgslinestring.h
  66. +6 −5 src/core/geometry/qgsmulticurve.cpp
  67. +1 −1 src/core/geometry/qgsmulticurve.h
  68. +6 −5 src/core/geometry/qgsmultilinestring.cpp
  69. +1 −1 src/core/geometry/qgsmultilinestring.h
  70. +14 −15 src/core/geometry/qgsmultipoint.cpp
  71. +1 −1 src/core/geometry/qgsmultipoint.h
  72. +10 −9 src/core/geometry/qgsmultipolygon.cpp
  73. +1 −1 src/core/geometry/qgsmultipolygon.h
  74. +7 −6 src/core/geometry/qgsmultisurface.cpp
  75. +1 −1 src/core/geometry/qgsmultisurface.h
  76. +10 −9 src/core/geometry/qgspoint.cpp
  77. +1 −1 src/core/geometry/qgspoint.h
  78. +42 −23 src/core/qgsjsonutils.cpp
  79. +16 −7 src/core/qgsjsonutils.h
  80. +1 −0 src/gui/CMakeLists.txt
  81. +1 −0 src/plugins/coordinate_capture/CMakeLists.txt
  82. +1 −0 src/plugins/evis/CMakeLists.txt
  83. +1 −0 src/plugins/geometry_checker/CMakeLists.txt
  84. +1 −0 src/plugins/georeferencer/CMakeLists.txt
  85. +1 −0 src/plugins/globe/CMakeLists.txt
  86. +1 −0 src/plugins/gps_importer/CMakeLists.txt
  87. +1 −0 src/plugins/grass/CMakeLists.txt
  88. +1 −0 src/plugins/offline_editing/CMakeLists.txt
  89. +1 −0 src/plugins/topology/CMakeLists.txt
  90. +2 −1 src/providers/arcgisrest/CMakeLists.txt
  91. +1 −0 src/providers/db2/CMakeLists.txt
  92. +1 −0 src/providers/delimitedtext/CMakeLists.txt
  93. +1 −0 src/providers/gdal/CMakeLists.txt
  94. +1 −0 src/providers/geonode/CMakeLists.txt
  95. +1 −0 src/providers/gpx/CMakeLists.txt
  96. +1 −0 src/providers/grass/CMakeLists.txt
  97. +1 −0 src/providers/mdal/CMakeLists.txt
  98. +1 −0 src/providers/mssql/CMakeLists.txt
  99. +1 −0 src/providers/ogr/CMakeLists.txt
  100. +1 −0 src/providers/oracle/CMakeLists.txt
  101. +1 −0 src/providers/ows/CMakeLists.txt
  102. +1 −0 src/providers/postgres/CMakeLists.txt
  103. +3 −0 src/providers/spatialite/CMakeLists.txt
  104. +1 −0 src/providers/virtual/CMakeLists.txt
  105. +1 −0 src/providers/wcs/CMakeLists.txt
  106. +1 −0 src/providers/wfs/CMakeLists.txt
  107. +1 −0 src/providers/wms/CMakeLists.txt
  108. +1 −0 tests/bench/CMakeLists.txt
  109. +1 −0 tests/src/analysis/CMakeLists.txt
  110. +1 −0 tests/src/app/CMakeLists.txt
  111. +1 −0 tests/src/core/CMakeLists.txt
  112. +67 −26 tests/src/core/testqgsjsonutils.cpp
  113. +1 −0 tests/src/geometry_checker/CMakeLists.txt
  114. +1 −0 tests/src/gui/CMakeLists.txt
  115. +1 −0 tests/src/providers/CMakeLists.txt
  116. +1 −0 tests/src/server/wms/CMakeLists.txt
@@ -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.
You can’t perform that action at this time.