mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-06-15 20:29:34 +00:00
Draw an end to my json experimentations. simdjson is king. long live simdjson!
Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
47b7cb2a06
commit
b70f24a581
|
@ -187,30 +187,8 @@
|
|||
<ClInclude Include="byte_t.h" />
|
||||
<ClInclude Include="cycles_t.h" />
|
||||
<ClInclude Include="cycle_t.h" />
|
||||
<ClInclude Include="nlohmann\json.hpp" />
|
||||
<ClInclude Include="opcode_test_suite_t.h" />
|
||||
<ClInclude Include="ram_t.h" />
|
||||
<ClInclude Include="rapidjson\allocators.h" />
|
||||
<ClInclude Include="rapidjson\cursorstreamwrapper.h" />
|
||||
<ClInclude Include="rapidjson\document.h" />
|
||||
<ClInclude Include="rapidjson\encodedstream.h" />
|
||||
<ClInclude Include="rapidjson\encodings.h" />
|
||||
<ClInclude Include="rapidjson\filereadstream.h" />
|
||||
<ClInclude Include="rapidjson\filewritestream.h" />
|
||||
<ClInclude Include="rapidjson\fwd.h" />
|
||||
<ClInclude Include="rapidjson\istreamwrapper.h" />
|
||||
<ClInclude Include="rapidjson\memorybuffer.h" />
|
||||
<ClInclude Include="rapidjson\memorystream.h" />
|
||||
<ClInclude Include="rapidjson\ostreamwrapper.h" />
|
||||
<ClInclude Include="rapidjson\pointer.h" />
|
||||
<ClInclude Include="rapidjson\prettywriter.h" />
|
||||
<ClInclude Include="rapidjson\rapidjson.h" />
|
||||
<ClInclude Include="rapidjson\reader.h" />
|
||||
<ClInclude Include="rapidjson\schema.h" />
|
||||
<ClInclude Include="rapidjson\stream.h" />
|
||||
<ClInclude Include="rapidjson\stringbuffer.h" />
|
||||
<ClInclude Include="rapidjson\uri.h" />
|
||||
<ClInclude Include="rapidjson\writer.h" />
|
||||
<ClInclude Include="simdjson\simdjson.h" />
|
||||
<ClInclude Include="state_t.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
|
@ -225,17 +203,6 @@
|
|||
<Project>{d8726a1b-bbfe-47ef-9860-26b90140ba66}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\packages\JsonCpp.Windows.1.9.2\build\JsonCpp.Windows.targets" Condition="Exists('..\..\packages\JsonCpp.Windows.1.9.2\build\JsonCpp.Windows.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\packages\JsonCpp.Windows.1.9.2\build\JsonCpp.Windows.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\JsonCpp.Windows.1.9.2\build\JsonCpp.Windows.targets'))" />
|
||||
</Target>
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
</Project>
|
|
@ -9,15 +9,9 @@
|
|||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\nlohmann">
|
||||
<UniqueIdentifier>{1b676a2e-dff7-46aa-b021-f4319b0419d7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\simdjson">
|
||||
<UniqueIdentifier>{92d132eb-117f-4f61-bad7-de75aa3cb6cf}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\rapidjson">
|
||||
<UniqueIdentifier>{4f98c949-9b35-4a51-b579-8551931bd9c2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="tests.cpp">
|
||||
|
@ -70,9 +64,6 @@
|
|||
<ClInclude Include="TestRunner.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="nlohmann\json.hpp">
|
||||
<Filter>Header Files\nlohmann</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="simdjson\simdjson.h">
|
||||
<Filter>Header Files\simdjson</Filter>
|
||||
</ClInclude>
|
||||
|
@ -85,74 +76,8 @@
|
|||
<ClInclude Include="ram_t.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\allocators.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\cursorstreamwrapper.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\document.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\encodedstream.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\encodings.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\filereadstream.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\filewritestream.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\fwd.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\istreamwrapper.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\memorybuffer.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\memorystream.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\ostreamwrapper.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\pointer.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\prettywriter.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\rapidjson.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\reader.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\schema.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\stream.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\stringbuffer.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\uri.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rapidjson\writer.h">
|
||||
<Filter>Header Files\rapidjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="byte_t.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,118 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
#include "byte_t.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
|
||||
byte_t::byte_t(simdjson::dom::element input) noexcept
|
||||
: byte_t(input.get_array()) {}
|
||||
|
||||
#ifdef JSON_ACCESS_DATA_VIA_OBJECT
|
||||
|
||||
byte_t::byte_t(simdjson::dom::array input) noexcept
|
||||
: m_raw(input) {}
|
||||
|
||||
#else // JSON_ACCESS_DATA_VIA_OBJECT
|
||||
|
||||
#ifdef JSON_PREFER_ITERATOR_TO_INDEX
|
||||
|
||||
byte_t::byte_t(simdjson::dom::array input) noexcept {
|
||||
assert(input.size() == 2);
|
||||
auto iterator = input.begin();
|
||||
m_address = (uint16_t)(int64_t)*iterator;
|
||||
m_value = (uint8_t)(int64_t)*++iterator;
|
||||
}
|
||||
|
||||
#else // JSON_PREFER_ITERATOR_TO_INDEX
|
||||
|
||||
byte_t::byte_t(simdjson::dom::array input) noexcept
|
||||
: m_address((uint16_t)(int64_t)input.at(0)),
|
||||
m_value((uint8_t)(int64_t)input.at(1)) {
|
||||
assert(input.size() == 2);
|
||||
}
|
||||
|
||||
#endif // JSON_PREFER_ITERATOR_TO_INDEX
|
||||
|
||||
#endif // JSON_ACCESS_DATA_VIA_OBJECT
|
||||
|
||||
#endif // USE_SIMDJSON_JSON
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
|
||||
#ifdef JSON_ACCESS_DATA_VIA_OBJECT
|
||||
|
||||
byte_t::byte_t(const rapidjson::Value& input)
|
||||
: m_raw(input) {}
|
||||
|
||||
#else
|
||||
|
||||
byte_t::byte_t(const rapidjson::Value& input)
|
||||
: m_address((uint16_t)input[0].GetInt64()),
|
||||
m_value((uint8_t)input[1].GetInt64()) {}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
|
||||
byte_t::byte_t(const boost::json::value& input) noexcept
|
||||
: byte_t(input.get_array()) {}
|
||||
|
||||
|
||||
#ifdef JSON_ACCESS_DATA_VIA_OBJECT
|
||||
|
||||
byte_t::byte_t(const boost::json::array& input) noexcept
|
||||
: m_raw(input) {}
|
||||
|
||||
#else
|
||||
|
||||
byte_t::byte_t(const boost::json::array& input) noexcept
|
||||
: m_address((uint16_t)input[0].get_int64()),
|
||||
m_value((uint8_t)input[1].get_int64()) {
|
||||
assert(input.size() == 2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
|
||||
#ifdef JSON_ACCESS_DATA_VIA_OBJECT
|
||||
|
||||
byte_t::byte_t(const nlohmann::json& input) noexcept
|
||||
: m_raw(input) {}
|
||||
|
||||
#else
|
||||
|
||||
byte_t::byte_t(const nlohmann::json& input) noexcept
|
||||
: m_address(input[0].get<uint16_t>()),
|
||||
m_value(input[1].get<uint8_t>()) {
|
||||
assert(input.size() == 2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
|
||||
#ifdef JSON_ACCESS_DATA_VIA_OBJECT
|
||||
|
||||
byte_t::byte_t(const Json::Value& input)
|
||||
: m_raw(input) {}
|
||||
|
||||
#else
|
||||
|
||||
byte_t::byte_t(const Json::Value& input)
|
||||
: m_address((uint16_t)input[0].asInt64()),
|
||||
m_value((uint8_t)input[1].asInt64()) {
|
||||
assert(input.size() == 2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,105 +2,16 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
# include "simdjson/simdjson.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
# include "rapidjson/document.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
# include <boost/json.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
# include "nlohmann/json.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
# include <json/json.h>
|
||||
#endif
|
||||
#include "simdjson/simdjson.h"
|
||||
|
||||
class byte_t final {
|
||||
private:
|
||||
|
||||
#ifdef JSON_ACCESS_DATA_VIA_OBJECT
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
simdjson::dom::array m_raw;
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
const rapidjson::Value& m_raw;
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
const boost::json::array& m_raw;
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
const nlohmann::json& m_raw;
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
const Json::Value& m_raw;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
uint16_t m_address = 0xffff;
|
||||
uint8_t m_value = 0xff;
|
||||
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
byte_t(simdjson::dom::element input) noexcept;
|
||||
byte_t(simdjson::dom::array input) noexcept;
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
byte_t(const rapidjson::Value& input);
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
byte_t(const boost::json::value& input) noexcept;
|
||||
byte_t(const boost::json::array& input) noexcept;
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
byte_t(const nlohmann::json& input) noexcept;
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
byte_t(const Json::Value& input);
|
||||
#endif
|
||||
|
||||
#ifdef JSON_ACCESS_DATA_VIA_OBJECT
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
[[nodiscard]] auto address() const noexcept { return (uint16_t)(int64_t)*m_raw.begin(); }
|
||||
[[nodiscard]] auto value() const noexcept { return (uint8_t)(int64_t)m_raw.at(1); }
|
||||
#endif
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
[[nodiscard]] auto address() const noexcept { return (uint16_t)m_raw[0].GetInt64(); }
|
||||
[[nodiscard]] auto value() const noexcept { return (uint8_t)m_raw[1].GetInt64(); }
|
||||
#endif
|
||||
#ifdef USE_BOOST_JSON
|
||||
[[nodiscard]] auto address() const noexcept { return (uint16_t)m_raw[0].get_int64(); }
|
||||
[[nodiscard]] auto value() const noexcept { return (uint8_t)m_raw[1].get_int64(); }
|
||||
#endif
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
[[nodiscard]] auto address() const noexcept { return m_raw[0].get<uint16_t>(); }
|
||||
[[nodiscard]] auto value() const noexcept { return m_raw[1].get<uint8_t>(); }
|
||||
#endif
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
[[nodiscard]] auto address() const noexcept { return (uint16_t)m_raw[0].asInt64(); }
|
||||
[[nodiscard]] auto value() const noexcept { return (uint8_t)m_raw[1].asInt64(); }
|
||||
#endif
|
||||
#else
|
||||
[[nodiscard]] constexpr auto address() const noexcept { return m_address; }
|
||||
[[nodiscard]] constexpr auto value() const noexcept { return m_value; }
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -24,13 +24,9 @@ cycle_t::cycle_t(uint16_t address, uint8_t value, action_t action) noexcept
|
|||
m_value(value),
|
||||
m_action(action) {}
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
|
||||
cycle_t::cycle_t(simdjson::dom::element input) noexcept
|
||||
: cycle_t(input.get_array()) {}
|
||||
|
||||
#ifdef JSON_PREFER_ITERATOR_TO_INDEX
|
||||
|
||||
cycle_t::cycle_t(simdjson::dom::array input) noexcept {
|
||||
assert(input.size() == 3);
|
||||
auto iterator = input.begin();
|
||||
|
@ -38,61 +34,3 @@ cycle_t::cycle_t(simdjson::dom::array input) noexcept {
|
|||
m_value = (uint8_t)(int64_t)*++iterator;
|
||||
m_action = to_action((std::string)*++iterator);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
cycle_t::cycle_t(simdjson::dom::array input) noexcept
|
||||
: m_address((uint16_t)(int64_t)input.at(0)),
|
||||
m_value((uint8_t)(int64_t)input.at(1)),
|
||||
m_action(to_action((std::string)input.at(2))) {
|
||||
assert(input.size() == 3);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
|
||||
cycle_t::cycle_t(const rapidjson::Value& input)
|
||||
: m_address((uint16_t)input[0].GetInt64()),
|
||||
m_value((uint8_t)input[1].GetInt64()),
|
||||
m_action(to_action(input[2].GetString())) {}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
|
||||
cycle_t::cycle_t(const boost::json::value& input) noexcept
|
||||
: cycle_t(input.get_array()) {}
|
||||
|
||||
cycle_t::cycle_t(const boost::json::array& input) noexcept
|
||||
: m_address((uint16_t)input[0].get_int64()),
|
||||
m_value((uint8_t)input[1].get_int64()),
|
||||
m_action(to_action((std::string)input[2].get_string())) {
|
||||
assert(input.size() == 3);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
|
||||
cycle_t::cycle_t(const nlohmann::json& input) noexcept
|
||||
: m_address(input[0].get<uint16_t>()),
|
||||
m_value(input[1].get<uint8_t>()),
|
||||
m_action(to_action(input[2].get<std::string>())) {
|
||||
assert(input.size() == 3);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
|
||||
cycle_t::cycle_t(const Json::Value& input)
|
||||
: m_address((uint16_t)input[0].asInt64()),
|
||||
m_value((uint8_t)input[1].asInt64()),
|
||||
m_action(to_action(input[2].asString())) {
|
||||
assert(input.size() == 3);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,25 +3,7 @@
|
|||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
# include "simdjson/simdjson.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
# include "rapidjson/document.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
# include <boost/json.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
# include "nlohmann/json.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
# include <json/json.h>
|
||||
#endif
|
||||
#include "simdjson/simdjson.h"
|
||||
|
||||
class cycle_t final {
|
||||
public:
|
||||
|
@ -38,27 +20,8 @@ public:
|
|||
|
||||
cycle_t(uint16_t address, uint8_t value, action_t action) noexcept;
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
cycle_t(simdjson::dom::element input) noexcept;
|
||||
cycle_t(simdjson::dom::array input) noexcept;
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
cycle_t(const rapidjson::Value& input);
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
cycle_t(const boost::json::value& input) noexcept;
|
||||
cycle_t(const boost::json::array& input) noexcept;
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
cycle_t(const nlohmann::json& input) noexcept;
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
cycle_t(const Json::Value& input);
|
||||
#endif
|
||||
|
||||
[[nodiscard]] constexpr auto address() const noexcept { return m_address; }
|
||||
[[nodiscard]] constexpr auto value() const noexcept { return m_value; }
|
||||
|
|
|
@ -10,60 +10,9 @@ void cycles_t::add(const cycle_t& cycle) {
|
|||
m_cycles.push_back(cycle);
|
||||
}
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
|
||||
cycles_t::cycles_t(simdjson::dom::array input) {
|
||||
assert(m_cycles.empty());
|
||||
m_cycles.reserve(input.size());
|
||||
for (const auto& entry : input)
|
||||
add(entry);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
|
||||
cycles_t::cycles_t(const rapidjson::Value& input) {
|
||||
assert(m_cycles.empty());
|
||||
m_cycles.reserve(input.Size());
|
||||
for (const auto& entry : input.GetArray())
|
||||
add(entry);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
|
||||
cycles_t::cycles_t(const boost::json::value& input)
|
||||
: cycles_t(input.get_array()) {}
|
||||
|
||||
cycles_t::cycles_t(const boost::json::array& input) {
|
||||
assert(m_cycles.empty());
|
||||
m_cycles.reserve(input.size());
|
||||
for (const auto& entry : input)
|
||||
add(entry);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
|
||||
cycles_t::cycles_t(const nlohmann::json& input) {
|
||||
assert(m_cycles.empty());
|
||||
m_cycles.reserve(input.size());
|
||||
for (const auto& entry : input)
|
||||
add(entry);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
|
||||
cycles_t::cycles_t(const Json::Value& input) {
|
||||
assert(m_cycles.empty());
|
||||
m_cycles.reserve(input.size());
|
||||
for (const auto& entry : input)
|
||||
add(entry);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,25 +2,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
# include "simdjson/simdjson.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
# include "rapidjson/document.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
# include <boost/json.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
# include "nlohmann/json.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
# include <json/json.h>
|
||||
#endif
|
||||
#include "simdjson/simdjson.h"
|
||||
|
||||
#include "cycle_t.h"
|
||||
|
||||
|
@ -30,27 +12,7 @@ private:
|
|||
|
||||
public:
|
||||
cycles_t(size_t reserved = 10);
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
cycles_t(simdjson::dom::array input);
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
cycles_t(const rapidjson::Value& input);
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
cycles_t(const boost::json::value& input);
|
||||
cycles_t(const boost::json::array& input);
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
cycles_t(const nlohmann::json& input);
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
cycles_t(const Json::Value& input);
|
||||
#endif
|
||||
|
||||
void add(const cycle_t& cycle);
|
||||
|
||||
|
|
|
@ -6,14 +6,7 @@
|
|||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
#ifdef JSON_PREFER_REUSE_OF_PARSER
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
std::unique_ptr<Json::CharReader> opcode_test_suite_t::m_parser;
|
||||
#endif
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
simdjson::dom::parser opcode_test_suite_t::m_parser;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
std::string opcode_test_suite_t::read(std::string path) {
|
||||
std::ifstream file(path, std::ios::in | std::ios::binary);
|
||||
|
@ -30,63 +23,8 @@ void opcode_test_suite_t::load() {
|
|||
m_contents = read(path());
|
||||
}
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
|
||||
void opcode_test_suite_t::parse() {
|
||||
m_raw = boost::json::parse(m_contents);
|
||||
m_contents.clear();
|
||||
m_contents.shrink_to_fit();}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
|
||||
void opcode_test_suite_t::parse() {
|
||||
m_raw = nlohmann::json::parse(m_contents);
|
||||
m_contents.clear();
|
||||
m_contents.shrink_to_fit();}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
|
||||
void opcode_test_suite_t::parse() {
|
||||
#ifdef JSON_PREFER_REUSE_OF_PARSER
|
||||
if (m_parser == nullptr)
|
||||
m_parser.reset(Json::CharReaderBuilder().newCharReader());
|
||||
if (!m_parser->parse(m_contents.data(), m_contents.data() + m_contents.size(), &m_raw, nullptr))
|
||||
throw std::runtime_error("Unable to parse tests");
|
||||
#else
|
||||
std::unique_ptr<Json::CharReader> parser(Json::CharReaderBuilder().newCharReader());
|
||||
if (!parser->parse(m_contents.data(), m_contents.data() + m_contents.size(), &m_raw, nullptr))
|
||||
throw std::runtime_error("Unable to parse tests");
|
||||
#endif
|
||||
m_contents.clear();
|
||||
m_contents.shrink_to_fit();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
|
||||
void opcode_test_suite_t::parse() {
|
||||
m_raw = m_parser.parse(m_contents);
|
||||
m_contents.clear();
|
||||
m_contents.shrink_to_fit();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
|
||||
void opcode_test_suite_t::parse() {
|
||||
#ifdef JSON_INSITU_PARSE
|
||||
m_raw.ParseInsitu((char*)m_contents.c_str());
|
||||
#else
|
||||
m_raw.Parse(m_contents);
|
||||
m_contents.clear();
|
||||
m_contents.shrink_to_fit();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,75 +2,26 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
# include <boost/json.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
# include "rapidjson/document.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
# include "nlohmann/json.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
# include <memory>
|
||||
# include <json/json.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
# include "simdjson/simdjson.h"
|
||||
#endif
|
||||
#include "simdjson/simdjson.h"
|
||||
|
||||
class opcode_test_suite_t final {
|
||||
private:
|
||||
#ifdef JSON_PREFER_REUSE_OF_PARSER
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
static std::unique_ptr<Json::CharReader> m_parser;
|
||||
#endif
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
// N.B.
|
||||
// The parser must be kept for the lifetime of any parsed data.
|
||||
// Therefore, it can only be used for one document at a time.
|
||||
static simdjson::dom::parser m_parser;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
[[nodiscard]] static std::string read(std::string path);
|
||||
|
||||
std::string m_path;
|
||||
std::string m_contents;
|
||||
#ifdef USE_BOOST_JSON
|
||||
boost::json::value m_raw;
|
||||
#endif
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
rapidjson::Document m_raw;
|
||||
#endif
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
nlohmann::json m_raw;
|
||||
#endif
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
Json::Value m_raw;
|
||||
#endif
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
simdjson::dom::element m_raw;
|
||||
#ifndef JSON_PREFER_REUSE_OF_PARSER
|
||||
// N.B. The parser must be kept for the lifetime of any parsed data.
|
||||
simdjson::dom::parser m_parser;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public:
|
||||
opcode_test_suite_t(std::string path);
|
||||
|
||||
[[nodiscard]] constexpr const auto& path() const noexcept { return m_path; }
|
||||
|
||||
#ifdef JSON_PREFER_PASS_BY_VALUE
|
||||
[[nodiscard]] const auto raw() const noexcept { return m_raw; }
|
||||
#else
|
||||
[[nodiscard]] constexpr const auto& raw() const noexcept { return m_raw; }
|
||||
#endif
|
||||
|
||||
void load(); // Reads into contents
|
||||
void parse(); // Parse the contents
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="JsonCpp.Windows" version="1.9.2" targetFramework="native" />
|
||||
</packages>
|
|
@ -6,60 +6,9 @@ void ram_t::add(byte_t byte) {
|
|||
m_bytes.push_back(byte);
|
||||
}
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
|
||||
ram_t::ram_t(simdjson::dom::array input) {
|
||||
assert(m_bytes.empty());
|
||||
m_bytes.reserve(input.size());
|
||||
for (auto entry : input)
|
||||
add(entry);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
|
||||
ram_t::ram_t(const rapidjson::Value& input) {
|
||||
assert(m_bytes.empty());
|
||||
m_bytes.reserve(input.Size());
|
||||
for (const auto& entry : input.GetArray())
|
||||
add(entry);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
|
||||
ram_t::ram_t(const boost::json::array& input) {
|
||||
assert(m_bytes.empty());
|
||||
m_bytes.reserve(input.size());
|
||||
for (const auto& entry : input)
|
||||
add(entry);
|
||||
}
|
||||
|
||||
ram_t::ram_t(const boost::json::value& input)
|
||||
: ram_t(input.get_array()) {}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
|
||||
ram_t::ram_t(const nlohmann::json& input) {
|
||||
assert(m_bytes.empty());
|
||||
m_bytes.reserve(input.size());
|
||||
for (const auto& entry : input)
|
||||
add(entry);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
|
||||
ram_t::ram_t(const Json::Value& input) {
|
||||
assert(m_bytes.empty());
|
||||
m_bytes.reserve(input.size());
|
||||
for (const auto& entry : input)
|
||||
add(entry);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,25 +3,7 @@
|
|||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
# include "simdjson/simdjson.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
# include "rapidjson/document.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
# include <boost/json.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
# include "nlohmann/json.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
# include <json/json.h>
|
||||
#endif
|
||||
#include "simdjson/simdjson.h"
|
||||
|
||||
#include "byte_t.h"
|
||||
|
||||
|
@ -30,26 +12,7 @@ private:
|
|||
std::vector<byte_t> m_bytes;
|
||||
|
||||
public:
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
ram_t(simdjson::dom::array input);
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
ram_t(const rapidjson::Value& input);
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
ram_t(const boost::json::value& input);
|
||||
ram_t(const boost::json::array& input);
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
ram_t(const nlohmann::json& input);
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
ram_t(const Json::Value& input);
|
||||
#endif
|
||||
|
||||
void add(byte_t byte);
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
#include "state_t.h"
|
||||
#include <cassert>
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
|
||||
state_t::state_t(const simdjson::dom::element serialised)
|
||||
: m_pc((uint16_t)(int64_t)serialised["pc"]),
|
||||
|
@ -12,60 +9,3 @@ state_t::state_t(const simdjson::dom::element serialised)
|
|||
m_y((uint8_t)(int64_t)serialised["y"]),
|
||||
m_p((uint8_t)(int64_t)serialised["p"]),
|
||||
m_ram(serialised["ram"].get_array()) {}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
|
||||
state_t::state_t(const rapidjson::Value& serialised)
|
||||
: m_pc((uint16_t)serialised["pc"].GetInt64()),
|
||||
m_s((uint8_t)serialised["s"].GetInt64()),
|
||||
m_a((uint8_t)serialised["a"].GetInt64()),
|
||||
m_x((uint8_t)serialised["x"].GetInt64()),
|
||||
m_y((uint8_t)serialised["y"].GetInt64()),
|
||||
m_p((uint8_t)serialised["p"].GetInt64()),
|
||||
m_ram(serialised["ram"]) {}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
|
||||
state_t::state_t(const boost::json::object& serialised)
|
||||
: m_pc((uint16_t)serialised.at("pc").get_int64()),
|
||||
m_s((uint8_t)serialised.at("s").get_int64()),
|
||||
m_a((uint8_t)serialised.at("a").get_int64()),
|
||||
m_x((uint8_t)serialised.at("x").get_int64()),
|
||||
m_y((uint8_t)serialised.at("y").get_int64()),
|
||||
m_p((uint8_t)serialised.at("p").get_int64()),
|
||||
m_ram(serialised.at("ram")) {}
|
||||
|
||||
state_t::state_t(const boost::json::value& serialised)
|
||||
: state_t(serialised.as_object()) {}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
|
||||
state_t::state_t(const nlohmann::json& serialised)
|
||||
: m_pc(serialised["pc"].get<uint16_t>()),
|
||||
m_s(serialised["s"].get<uint8_t>()),
|
||||
m_a(serialised["a"].get<uint8_t>()),
|
||||
m_x(serialised["x"].get<uint8_t>()),
|
||||
m_y(serialised["y"].get<uint8_t>()),
|
||||
m_p(serialised["p"].get<uint8_t>()),
|
||||
m_ram(serialised["ram"]) {}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
|
||||
state_t::state_t(const Json::Value& serialised)
|
||||
: m_pc((uint16_t)serialised["pc"].asInt64()),
|
||||
m_s((uint8_t)serialised["s"].asInt64()),
|
||||
m_a((uint8_t)serialised["a"].asInt64()),
|
||||
m_x((uint8_t)serialised["x"].asInt64()),
|
||||
m_y((uint8_t)serialised["y"].asInt64()),
|
||||
m_p((uint8_t)serialised["p"].asInt64()),
|
||||
m_ram(serialised["ram"]) {}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,25 +2,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
# include "simdjson/simdjson.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
# include "rapidjson/document.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
# include <boost/json.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
# include "nlohmann/json.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
# include <json/json.h>
|
||||
#endif
|
||||
#include "simdjson/simdjson.h"
|
||||
|
||||
#include "ram_t.h"
|
||||
|
||||
|
@ -35,26 +17,7 @@ private:
|
|||
ram_t m_ram;
|
||||
|
||||
public:
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
state_t(simdjson::dom::element serialised);
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
state_t(const rapidjson::Value& serialised);
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
state_t(const boost::json::object& serialised);
|
||||
state_t(const boost::json::value& serialised);
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
state_t(const nlohmann::json& serialised);
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
state_t(const Json::Value& serialised);
|
||||
#endif
|
||||
|
||||
[[nodiscard]] constexpr auto pc() const noexcept { return m_pc; }
|
||||
[[nodiscard]] constexpr auto s() const noexcept { return m_s; }
|
||||
|
|
|
@ -21,43 +21,4 @@
|
|||
#include <Disassembly.h>
|
||||
#include <Symbols.h>
|
||||
|
||||
//#define TEST_JSON_PERFORMANCE
|
||||
|
||||
#define USE_SIMDJSON_JSON // 13 seconds (19)
|
||||
//#define USE_RAPIDJSON_JSON // 19 seconds (22)
|
||||
//#define USE_BOOST_JSON // 26 seconds (32)
|
||||
//#define USE_NLOHMANN_JSON // 56 seconds (65)
|
||||
//#define USE_JSONCPP_JSON // 80 seconds (87)
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
# define JSON_PREFER_PASS_BY_VALUE
|
||||
# define JSON_PREFER_REUSE_OF_PARSER
|
||||
# define JSON_PREFER_ITERATOR_TO_INDEX
|
||||
# define JSON_ACCESS_DATA_VIA_OBJECT
|
||||
# include "simdjson/simdjson.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
# define RAPIDJSON_HAS_STDSTRING 1
|
||||
# define RAPIDJSON_SSE42
|
||||
# define JSON_INSITU_PARSE
|
||||
# define JSON_ACCESS_DATA_VIA_OBJECT
|
||||
# include "rapidjson/document.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
# define JSON_ACCESS_DATA_VIA_OBJECT
|
||||
# include <boost/json.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
# define JSON_USE_IMPLICIT_CONVERSIONS 0
|
||||
# define JSON_ACCESS_DATA_VIA_OBJECT
|
||||
# include "nlohmann/json.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
# define JSON_PREFER_REUSE_OF_PARSER
|
||||
# define JSON_ACCESS_DATA_VIA_OBJECT
|
||||
# include <json/json.h>
|
||||
#endif
|
||||
#include "simdjson/simdjson.h"
|
||||
|
|
|
@ -2,55 +2,8 @@
|
|||
#include "test_t.h"
|
||||
#include <cassert>
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
|
||||
test_t::test_t(const simdjson::dom::element serialised)
|
||||
: m_name(serialised["name"]),
|
||||
m_initial_state(serialised["initial"]),
|
||||
m_final_state(serialised["final"]),
|
||||
m_cycles(serialised["cycles"].get_array()) {}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
|
||||
test_t::test_t(const rapidjson::Value& serialised)
|
||||
: m_name(serialised["name"].GetString()),
|
||||
m_initial_state(serialised["initial"]),
|
||||
m_final_state(serialised["final"]),
|
||||
m_cycles(serialised["cycles"]) {}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
|
||||
test_t::test_t(const boost::json::object& serialised)
|
||||
: m_name(serialised.at("name").get_string()),
|
||||
m_initial_state(serialised.at("initial")),
|
||||
m_final_state(serialised.at("final")),
|
||||
m_cycles(serialised.at("cycles")) {}
|
||||
|
||||
test_t::test_t(const boost::json::value& serialised)
|
||||
: test_t(serialised.get_object()) {}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
|
||||
test_t::test_t(const nlohmann::json& serialised)
|
||||
: m_name(serialised["name"].get<std::string>()),
|
||||
m_initial_state(serialised["initial"]),
|
||||
m_final_state(serialised["final"]),
|
||||
m_cycles(serialised["cycles"]) {}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
|
||||
test_t::test_t(const Json::Value& serialised)
|
||||
: m_name(serialised["name"].asString()),
|
||||
m_initial_state(serialised["initial"]),
|
||||
m_final_state(serialised["final"]),
|
||||
m_cycles(serialised["cycles"]) {}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,25 +2,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
# include "simdjson/simdjson.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
# include "rapidjson/document.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
# include <boost/json.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
# include "nlohmann/json.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
# include <json/json.h>
|
||||
#endif
|
||||
#include "simdjson/simdjson.h"
|
||||
|
||||
#include "cycles_t.h"
|
||||
#include "state_t.h"
|
||||
|
@ -33,27 +15,7 @@ private:
|
|||
cycles_t m_cycles;
|
||||
|
||||
public:
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
test_t(simdjson::dom::element serialised);
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
test_t(const rapidjson::Value& serialised);
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
test_t(const boost::json::object& serialised);
|
||||
test_t(const boost::json::value& serialised);
|
||||
#endif
|
||||
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
test_t(const nlohmann::json& serialised);
|
||||
#endif
|
||||
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
test_t(const Json::Value& serialised);
|
||||
#endif
|
||||
|
||||
[[nodiscard]] constexpr const auto& name() const noexcept { return m_name; }
|
||||
[[nodiscard]] constexpr const auto& initial_state() const noexcept { return m_initial_state; }
|
||||
|
|
|
@ -24,23 +24,7 @@ int main() {
|
|||
opcode.load();
|
||||
opcode.parse();
|
||||
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
const auto opcode_test_array = opcode.raw().get_array();
|
||||
#endif
|
||||
#ifdef USE_RAPIDJSON_JSON
|
||||
const auto& opcode_test_array = opcode.raw().GetArray();
|
||||
#endif
|
||||
#ifdef USE_BOOST_JSON
|
||||
const auto& opcode_test_array = opcode.raw().get_array();
|
||||
#endif
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
const auto& opcode_test_array = opcode.raw();
|
||||
assert(opcode_test_array.is_array());
|
||||
#endif
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
const auto& opcode_test_array = opcode.raw();
|
||||
assert(opcode_test_array.is_array());
|
||||
#endif
|
||||
|
||||
bool opcode_bad = false;
|
||||
for (const auto& opcode_test_element : opcode_test_array) {
|
||||
|
@ -48,7 +32,6 @@ int main() {
|
|||
const auto opcode_test = test_t(opcode_test_element);
|
||||
|
||||
TestRunner runner(opcode_test);
|
||||
#ifndef TEST_JSON_PERFORMANCE
|
||||
const auto good = runner.check();
|
||||
if (!good) {
|
||||
if (!opcode_bad) {
|
||||
|
@ -58,7 +41,6 @@ int main() {
|
|||
opcode_bad = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (opcode_bad)
|
||||
++bad_opcode_count;
|
||||
|
@ -71,4 +53,4 @@ int main() {
|
|||
<< "Elapsed time: " << seconds << " seconds"
|
||||
<< ", bad opcode count: " << bad_opcode_count
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user