diff --git a/benchmark/benchmarker.h b/benchmark/benchmarker.h index d1a46577e..b90a5a407 100644 --- a/benchmark/benchmarker.h +++ b/benchmark/benchmarker.h @@ -445,7 +445,7 @@ struct benchmarker { return 100.0 * a / b; } - void print(bool tabbed_output) const { + void print(bool tabbed_output, bool stage1_only) const { if (tabbed_output) { char* filename_copy = reinterpret_cast(malloc(strlen(filename)+1)); SIMDJSON_PUSH_DISABLE_WARNINGS @@ -503,17 +503,21 @@ struct benchmarker { stats->blocks_with_16_structurals_flipped, percent(stats->blocks_with_16_structurals_flipped, stats->blocks)); } printf("\n"); - printf("All Stages (excluding allocation)\n"); - print_aggregate("| " , all_stages_without_allocation.best); - // frequently, allocation is a tiny fraction of the running time so we omit it - if(allocate_stage.best.elapsed_sec() > 0.01 * all_stages_without_allocation.best.elapsed_sec()) { - printf("|- Allocation\n"); - print_aggregate("| ", allocate_stage.best); + if(!stage1_only) { + printf("All Stages (excluding allocation)\n"); + print_aggregate("| " , all_stages_without_allocation.best); + // frequently, allocation is a tiny fraction of the running time so we omit it + if(allocate_stage.best.elapsed_sec() > 0.01 * all_stages_without_allocation.best.elapsed_sec()) { + printf("|- Allocation\n"); + print_aggregate("| ", allocate_stage.best); + } } printf("|- Stage 1\n"); print_aggregate("| ", stage1.best); - printf("|- Stage 2\n"); - print_aggregate("| ", stage2.best); + if(!stage1_only) { + printf("|- Stage 2\n"); + print_aggregate("| ", stage2.best); + } if (collector.has_events()) { double freq1 = (stage1.best.cycles() / stage1.best.elapsed_sec()) / 1000000000.0; double freq2 = (stage2.best.cycles() / stage2.best.elapsed_sec()) / 1000000000.0; diff --git a/benchmark/dom/parse.cpp b/benchmark/dom/parse.cpp index 9a9c91269..d26622da1 100644 --- a/benchmark/dom/parse.cpp +++ b/benchmark/dom/parse.cpp @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) { if (!options.verbose) { progress.erase(); } for (size_t i=0; iprint(options.tabbed_output); + benchmarkers[i]->print(options.tabbed_output, options.stage1_only); delete benchmarkers[i]; } diff --git a/cmake/developer-options.cmake b/cmake/developer-options.cmake index 0db8e5adf..0d2da7501 100644 --- a/cmake/developer-options.cmake +++ b/cmake/developer-options.cmake @@ -117,7 +117,12 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_MACOSX_RPATH OFF) set(CMAKE_THREAD_PREFER_PTHREAD ON) set(THREADS_PREFER_PTHREAD_FLAG ON) +set(SIMDJSON_STRUCTURAL_INDEXER_STEP CACHE STRING "the SIMDJSON_STRUCTURAL_INDEXER_STEP variable") +if(SIMDJSON_STRUCTURAL_INDEXER_STEP) + message(STATUS "Setting SIMDJSON_STRUCTURAL_INDEXER_STEP to ${SIMDJSON_STRUCTURAL_INDEXER_STEP}.") + add_compile_definitions(SIMDJSON_STRUCTURAL_INDEXER_STEP=${SIMDJSON_STRUCTURAL_INDEXER_STEP}) +endif() # LTO seems to create all sorts of fun problems. Let us # disable temporarily. #include(CheckIPOSupported) diff --git a/src/generic/stage1/json_structural_indexer.h b/src/generic/stage1/json_structural_indexer.h index 471f566b6..cf69fa0e2 100644 --- a/src/generic/stage1/json_structural_indexer.h +++ b/src/generic/stage1/json_structural_indexer.h @@ -102,8 +102,11 @@ public: #if SIMDJSON_PREFER_REVERSE_BITS bits = reverse_bits(bits); #endif - +#ifdef SIMDJSON_STRUCTURAL_INDEXER_STEP + static constexpr const int STEP = SIMDJSON_STRUCTURAL_INDEXER_STEP; +#else static constexpr const int STEP = 2; +#endif static constexpr const int STEP_UNTIL = 24; write_indexes_stepped<0, STEP_UNTIL, STEP>(idx, bits, cnt);