New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fast (and beautiful) json serializing #9832
Conversation
... 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()
Since this commit we're having troubles to compile QField. |
@m-kuhn no, the headers are only available in |
@@ -3,6 +3,8 @@ | |||
|
|||
SET(QGIS_CORE_SRCS | |||
${CMAKE_SOURCE_DIR}/external/kdbush/include/kdbush.hpp | |||
${CMAKE_SOURCE_DIR}/external/nlohmann/json.hpp | |||
${CMAKE_SOURCE_DIR}/external/nlohmann/json_fwd.hpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these files need to be compiled? I think they are included anyway so no reason to put them into the SRCS here (and not sure about the kdbush either @nyalldawson )
Instead the external/CMakeFiles.txt should probably include the logic to install them onto the system since they are de facto no longer "external" for QGIS - apart from code organization inside the source tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although kdbush is a bit different, it's currently only used in a private header (which is not deployed on an installation), so that does not need to be shipped.
See followup, it's not that I might want something, it's that currently building standalone apps based on QGIS |
@m-kuhn I made a quick test here and I think you can safely remove them from |
@elpaso the bigger issue is that they need to be installed. |
@elpaso is the problem clear to you? What would you propose? |
@m-kuhn I'm not sure, because I've never built a C++ standalone application based on QGIS and I have no test cases. If I understand this correctly, the problem is that in order to use QGIS libraries you need to include
Your suggestion (if I got that right) to install/copy the json headers to the QGIS include directory looks correct to me but as I said I cannot reproduce or test this issue. |
Basically
should be "are not installed anywhere".
It should be straightforward: when do you a |
Follow up from #9725
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 (this is the reason why I abandoned it).
Note that there is an overhead in the benchmarks in converting to
QString
that will not be necessary in all scenarios, this means that this implementation will potentially be even more performant than in the above tests (QGIS server: I'm looking at you).But speed is not everything: the json library offers a wonderful and easy to use API: https://github.com/nlohmann/json
I could spot a single small difference between the output generated by the new library and the old one and it is:
Note that the json standard allows to protect a forward slash but it does not enforce it.
Funded by: QCooperative.net