mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Compare commits
6 Commits
lemire/features
...
cxx20
| Author | SHA1 | Date | |
|---|---|---|---|
| 751d41ab1e | |||
| 25d8709b18 | |||
| 33b014dd23 | |||
| c8f5f376a0 | |||
| 2e51e7bb8d | |||
| 4037b48e6a |
@@ -0,0 +1,33 @@
|
|||||||
|
name: Ubuntu 22.04 CI (GCC 12, CXX 20)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ubuntu-build:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
mkdir builddebug &&
|
||||||
|
cd builddebug &&
|
||||||
|
CXX=g++-12 cmake -DSIMDJSON_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cd .. &&
|
||||||
|
mkdir build &&
|
||||||
|
cd build &&
|
||||||
|
CXX=g++-12 cmake -DSIMDJSON_CXX_STANDARD=20 -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cmake --install . &&
|
||||||
|
echo -e '#include <simdjson.h>\nint main(int argc,char**argv) {simdjson::dom::parser parser;simdjson::dom::element tweets = parser.load(argv[1]); }' > tmp.cpp && c++ -Idestination/include -Ldestination/lib -std=c++17 -Wl,-rpath,destination/lib -o linkandrun tmp.cpp -lsimdjson && ./linkandrun jsonexamples/twitter.json &&
|
||||||
|
cd ../tests/installation_tests/find &&
|
||||||
|
mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build .
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
name: VS17-CI CXX20
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
name: windows-vs17
|
||||||
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- {gen: Visual Studio 17 2022, arch: Win32, shared: ON}
|
||||||
|
- {gen: Visual Studio 17 2022, arch: Win32, shared: OFF}
|
||||||
|
- {gen: Visual Studio 17 2022, arch: x64, shared: ON}
|
||||||
|
- {gen: Visual Studio 17 2022, arch: x64, shared: OFF}
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Configure
|
||||||
|
run: |
|
||||||
|
cmake -DSIMDJSON_CXX_STANDARD=20 -G "${{matrix.gen}}" -A ${{matrix.arch}} -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_COMPETITION=OFF -DBUILD_SHARED_LIBS=${{matrix.shared}} -B build
|
||||||
|
- name: Build Debug
|
||||||
|
run: cmake --build build --config Debug --verbose
|
||||||
|
- name: Build Release
|
||||||
|
run: cmake --build build --config Release --verbose
|
||||||
|
- name: Run Release tests
|
||||||
|
run: |
|
||||||
|
cd build
|
||||||
|
ctest -C Release -LE explicitonly --output-on-failure
|
||||||
|
- name: Run Debug tests
|
||||||
|
run: |
|
||||||
|
cd build
|
||||||
|
ctest -C Debug -LE explicitonly --output-on-failure
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
cmake --install build --config Release
|
||||||
|
- name: Test Installation
|
||||||
|
run: |
|
||||||
|
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -B build_install_test tests/installation_tests/find
|
||||||
|
cmake --build build_install_test --config Release
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#define __BENCHMARKER_H
|
#define __BENCHMARKER_H
|
||||||
|
|
||||||
#include "event_counter.h"
|
#include "event_counter.h"
|
||||||
#include "simdjson.h" // For SIMDJSON_DISABLE_DEPRECATED_WARNINGS
|
#include "simdjson.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ endif()
|
|||||||
|
|
||||||
# We compile tools, tests, etc. with C++ 17. Override yourself if you need on a
|
# We compile tools, tests, etc. with C++ 17. Override yourself if you need on a
|
||||||
# target.
|
# target.
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(SIMDJSON_CXX_STANDARD 17 CACHE STRING "the C++ standard to use for simdjson")
|
||||||
|
set(CMAKE_CXX_STANDARD ${SIMDJSON_CXX_STANDARD})
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
set(CMAKE_MACOSX_RPATH OFF)
|
set(CMAKE_MACOSX_RPATH OFF)
|
||||||
|
|||||||
@@ -122,6 +122,9 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
|||||||
|
|
||||||
#define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
|
#define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
|
||||||
// gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
|
// gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
|
||||||
|
// We do it separately for clang since it has different warnings.
|
||||||
|
#ifdef __clang__
|
||||||
|
// clang is missing -Wmaybe-uninitialized.
|
||||||
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
||||||
@@ -134,6 +137,22 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
|||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
|
||||||
|
#else // __clang__
|
||||||
|
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wconversion) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wattributes) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wnon-virtual-dtor) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wmaybe-uninitialized)
|
||||||
|
#endif // __clang__
|
||||||
|
|
||||||
#define SIMDJSON_PRAGMA(P) _Pragma(#P)
|
#define SIMDJSON_PRAGMA(P) _Pragma(#P)
|
||||||
#define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
|
#define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
|
||||||
#if defined(SIMDJSON_CLANG_VISUAL_STUDIO)
|
#if defined(SIMDJSON_CLANG_VISUAL_STUDIO)
|
||||||
|
|||||||
@@ -21,6 +21,11 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// By default, we allow AVX512.
|
||||||
|
#ifndef SIMDJSON_AVX512_ALLOWED
|
||||||
|
#define SIMDJSON_AVX512_ALLOWED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
// Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected
|
// Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected
|
||||||
// at runtime.
|
// at runtime.
|
||||||
#ifndef SIMDJSON_IMPLEMENTATION_ICELAKE
|
#ifndef SIMDJSON_IMPLEMENTATION_ICELAKE
|
||||||
|
|||||||
@@ -81,8 +81,10 @@ def dofile(fid, prepath, filename):
|
|||||||
# print(f"// dofile: invoked with prepath={prepath}, filename={filename}",file=fid)
|
# print(f"// dofile: invoked with prepath={prepath}, filename={filename}",file=fid)
|
||||||
file = os.path.join(prepath, filename)
|
file = os.path.join(prepath, filename)
|
||||||
RELFILE = os.path.relpath(file, PROJECTPATH)
|
RELFILE = os.path.relpath(file, PROJECTPATH)
|
||||||
|
# Windows use \ as a directory separator, but we do not want that:
|
||||||
|
OSRELFILE = RELFILE.replace('\\','/')
|
||||||
# Last lines are always ignored. Files should end by an empty lines.
|
# Last lines are always ignored. Files should end by an empty lines.
|
||||||
print(f"/* begin file {RELFILE} */", file=fid)
|
print(f"/* begin file {OSRELFILE} */", file=fid)
|
||||||
includepattern = re.compile('^#include "(.*)"')
|
includepattern = re.compile('^#include "(.*)"')
|
||||||
redefines_simdjson_implementation = re.compile('^#define\s+SIMDJSON_IMPLEMENTATION\s+(.*)')
|
redefines_simdjson_implementation = re.compile('^#define\s+SIMDJSON_IMPLEMENTATION\s+(.*)')
|
||||||
undefines_simdjson_implementation = re.compile('^#undef\s+SIMDJSON_IMPLEMENTATION\s*$')
|
undefines_simdjson_implementation = re.compile('^#undef\s+SIMDJSON_IMPLEMENTATION\s*$')
|
||||||
@@ -114,7 +116,7 @@ def dofile(fid, prepath, filename):
|
|||||||
else:
|
else:
|
||||||
# copy the line, with SIMDJSON_IMPLEMENTATION replace to what it is currently defined to
|
# copy the line, with SIMDJSON_IMPLEMENTATION replace to what it is currently defined to
|
||||||
print(uses_simdjson_implementation.sub(current_implementation+"\\1",line), file=fid)
|
print(uses_simdjson_implementation.sub(current_implementation+"\\1",line), file=fid)
|
||||||
print(f"/* end file {RELFILE} */", file=fid)
|
print(f"/* end file {OSRELFILE} */", file=fid)
|
||||||
|
|
||||||
|
|
||||||
# Get the generation date from git, so the output is reproducible.
|
# Get the generation date from git, so the output is reproducible.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* auto-generated on 2022-05-25 11:24:40 -0400. Do not edit! */
|
/* auto-generated on 2022-05-26 14:07:15 -0400. Do not edit! */
|
||||||
/* begin file src/simdjson.cpp */
|
/* begin file src/simdjson.cpp */
|
||||||
#include "simdjson.h"
|
#include "simdjson.h"
|
||||||
|
|
||||||
@@ -7589,6 +7589,9 @@ simdjson_really_inline error_code json_structural_indexer::finish(dom_parser_imp
|
|||||||
* naked intrinsics.
|
* naked intrinsics.
|
||||||
* TODO: make this code more elegant.
|
* TODO: make this code more elegant.
|
||||||
*/
|
*/
|
||||||
|
// Under GCC 12, the intrinsic _mm512_extracti32x4_epi32 may generate 'maybe uninitialized'.
|
||||||
|
// as a workaround, we disable warnings within the following function.
|
||||||
|
SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
|
||||||
namespace simdjson { namespace icelake { namespace { namespace stage1 {
|
namespace simdjson { namespace icelake { namespace { namespace stage1 {
|
||||||
simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
||||||
// In some instances, the next branch is expensive because it is mispredicted.
|
// In some instances, the next branch is expensive because it is mispredicted.
|
||||||
@@ -7623,6 +7626,7 @@ simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
|||||||
this->tail += count;
|
this->tail += count;
|
||||||
}
|
}
|
||||||
}}}}
|
}}}}
|
||||||
|
SIMDJSON_POP_DISABLE_WARNINGS
|
||||||
|
|
||||||
/* begin file src/generic/stage1/utf8_validator.h */
|
/* begin file src/generic/stage1/utf8_validator.h */
|
||||||
namespace simdjson {
|
namespace simdjson {
|
||||||
|
|||||||
+25
-1
@@ -1,4 +1,4 @@
|
|||||||
/* auto-generated on 2022-05-25 11:24:40 -0400. Do not edit! */
|
/* auto-generated on 2022-05-26 14:07:15 -0400. Do not edit! */
|
||||||
/* begin file include/simdjson.h */
|
/* begin file include/simdjson.h */
|
||||||
#ifndef SIMDJSON_H
|
#ifndef SIMDJSON_H
|
||||||
#define SIMDJSON_H
|
#define SIMDJSON_H
|
||||||
@@ -414,6 +414,9 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
|||||||
|
|
||||||
#define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
|
#define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
|
||||||
// gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
|
// gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
|
||||||
|
// We do it separately for clang since it has different warnings.
|
||||||
|
#ifdef __clang__
|
||||||
|
// clang is missing -Wmaybe-uninitialized.
|
||||||
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
||||||
@@ -426,6 +429,22 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
|||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
||||||
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
|
||||||
|
#else // __clang__
|
||||||
|
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Weffc++) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wconversion) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wattributes) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wnon-virtual-dtor) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable) \
|
||||||
|
SIMDJSON_DISABLE_GCC_WARNING(-Wmaybe-uninitialized)
|
||||||
|
#endif // __clang__
|
||||||
|
|
||||||
#define SIMDJSON_PRAGMA(P) _Pragma(#P)
|
#define SIMDJSON_PRAGMA(P) _Pragma(#P)
|
||||||
#define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
|
#define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
|
||||||
#if defined(SIMDJSON_CLANG_VISUAL_STUDIO)
|
#if defined(SIMDJSON_CLANG_VISUAL_STUDIO)
|
||||||
@@ -9482,6 +9501,11 @@ extern SIMDJSON_DLLIMPORTEXPORT const uint64_t thintable_epi8[256];
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// By default, we allow AVX512.
|
||||||
|
#ifndef SIMDJSON_AVX512_ALLOWED
|
||||||
|
#define SIMDJSON_AVX512_ALLOWED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
// Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected
|
// Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected
|
||||||
// at runtime.
|
// at runtime.
|
||||||
#ifndef SIMDJSON_IMPLEMENTATION_ICELAKE
|
#ifndef SIMDJSON_IMPLEMENTATION_ICELAKE
|
||||||
|
|||||||
@@ -114,6 +114,9 @@ simdjson_really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t>
|
|||||||
* naked intrinsics.
|
* naked intrinsics.
|
||||||
* TODO: make this code more elegant.
|
* TODO: make this code more elegant.
|
||||||
*/
|
*/
|
||||||
|
// Under GCC 12, the intrinsic _mm512_extracti32x4_epi32 may generate 'maybe uninitialized'.
|
||||||
|
// as a workaround, we disable warnings within the following function.
|
||||||
|
SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
|
||||||
namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { namespace { namespace stage1 {
|
namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { namespace { namespace stage1 {
|
||||||
simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
||||||
// In some instances, the next branch is expensive because it is mispredicted.
|
// In some instances, the next branch is expensive because it is mispredicted.
|
||||||
@@ -148,6 +151,7 @@ simdjson_really_inline void bit_indexer::write(uint32_t idx, uint64_t bits) {
|
|||||||
this->tail += count;
|
this->tail += count;
|
||||||
}
|
}
|
||||||
}}}}
|
}}}}
|
||||||
|
SIMDJSON_POP_DISABLE_WARNINGS
|
||||||
|
|
||||||
#include "generic/stage1/utf8_validator.h"
|
#include "generic/stage1/utf8_validator.h"
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using namespace simdjson;
|
|||||||
// This ensures the compiler can't rearrange them into the proper order (which causes it to work!)
|
// This ensures the compiler can't rearrange them into the proper order (which causes it to work!)
|
||||||
simdjson_never_inline bool check_point(simdjson_result<ondemand::value> xval, simdjson_result<ondemand::value> yval) {
|
simdjson_never_inline bool check_point(simdjson_result<ondemand::value> xval, simdjson_result<ondemand::value> yval) {
|
||||||
// Verify the expected release behavior
|
// Verify the expected release behavior
|
||||||
uint64_t x, y;
|
uint64_t x{}, y{};
|
||||||
if (!xval.get(x)) { return false; }
|
if (!xval.get(x)) { return false; }
|
||||||
if (!yval.get(y)) { return false; }
|
if (!yval.get(y)) { return false; }
|
||||||
std::cout << x << "," << y << std::endl;
|
std::cout << x << "," << y << std::endl;
|
||||||
|
|||||||
+30
-1
@@ -1,3 +1,4 @@
|
|||||||
|
#include <chrono>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
|
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@@ -38,6 +39,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
}
|
}
|
||||||
options.add_options()
|
options.add_options()
|
||||||
("a,arch", ss.str(), cxxopts::value<std::string>())
|
("a,arch", ss.str(), cxxopts::value<std::string>())
|
||||||
|
("t,timing", "Report only timing.")
|
||||||
("f,file", "File name.", cxxopts::value<std::string>())
|
("f,file", "File name.", cxxopts::value<std::string>())
|
||||||
("h,help", "Print usage.")
|
("h,help", "Print usage.")
|
||||||
;
|
;
|
||||||
@@ -79,7 +81,34 @@ int main(int argc, const char *argv[]) {
|
|||||||
size_t copy_len;
|
size_t copy_len;
|
||||||
error = simdjson::get_active_implementation()->minify((const uint8_t*)p.data(), p.length(), (uint8_t*)copy.data(), copy_len);
|
error = simdjson::get_active_implementation()->minify((const uint8_t*)p.data(), p.length(), (uint8_t*)copy.data(), copy_len);
|
||||||
if (error) { std::cerr << error << std::endl; return EXIT_FAILURE; }
|
if (error) { std::cerr << error << std::endl; return EXIT_FAILURE; }
|
||||||
printf("%s", copy.data());
|
/**
|
||||||
|
* If a user only wants to time the required time, we do not output
|
||||||
|
* the result and we simply do the processing in a tight loop.
|
||||||
|
* At this point in time, we can assume that the processing will
|
||||||
|
* succeed.
|
||||||
|
*/
|
||||||
|
if(result.count("timing")) {
|
||||||
|
uint64_t beforens = std::chrono::duration_cast<::std::chrono::nanoseconds>(
|
||||||
|
std::chrono::steady_clock::now().time_since_epoch())
|
||||||
|
.count();
|
||||||
|
error = simdjson::get_active_implementation()->minify((const uint8_t*)p.data(), p.length(), (uint8_t*)copy.data(), copy_len);
|
||||||
|
uint64_t afterns = std::chrono::duration_cast<::std::chrono::nanoseconds>(
|
||||||
|
std::chrono::steady_clock::now().time_since_epoch())
|
||||||
|
.count();
|
||||||
|
size_t times = 1;
|
||||||
|
while(afterns - beforens < 1000000000) {
|
||||||
|
error = simdjson::get_active_implementation()->minify((const uint8_t*)p.data(), p.length(), (uint8_t*)copy.data(), copy_len);
|
||||||
|
afterns = std::chrono::duration_cast<::std::chrono::nanoseconds>(
|
||||||
|
std::chrono::steady_clock::now().time_since_epoch())
|
||||||
|
.count();
|
||||||
|
times += 1;
|
||||||
|
}
|
||||||
|
if (error) { std::cerr << error << std::endl; return EXIT_FAILURE; }
|
||||||
|
printf("%.3f GB/s\n", double(p.length() * times) / double(afterns - beforens));
|
||||||
|
} else {
|
||||||
|
// This is the expected path:
|
||||||
|
printf("%s", copy.data());
|
||||||
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
#ifdef __cpp_exceptions
|
#ifdef __cpp_exceptions
|
||||||
} catch (const cxxopts::OptionException& e) {
|
} catch (const cxxopts::OptionException& e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user