Versions of the code that use Google DoubleConv.
This commit is contained in:
parent
6807abff96
commit
e104c020ef
14
Makefile
14
Makefile
|
@ -8,8 +8,9 @@
|
|||
|
||||
CXXFLAGS = -std=c++11 -g2 -O2 -march=native -Wall -Wextra -Wshadow -Iinclude -Ibenchmark/linux -Idependencies/double-conversion -Idependencies/rapidjson/include -Ldependencies/double-conversion/release
|
||||
LIBFLAGS = -ldouble-conversion
|
||||
EXECUTABLES=parse jsoncheck minifiercompetition parsingcompetition
|
||||
DOUBLEEXECUTABLES=parsedouble jsoncheckdouble parsingcompetitiondouble
|
||||
|
||||
EXECUTABLES=parse jsoncheck minifiercompetition parsingcompetition
|
||||
HEADERS=include/jsonparser/jsonparser.h include/jsonparser/common_defs.h include/jsonparser/jsonioutil.h benchmark/benchmark.h benchmark/linux/linux-perf-events.h include/jsonparser/simdjson_internal.h include/jsonparser/stage1_find_marks.h include/jsonparser/stage2_flatten.h include/jsonparser/stage3_ape_machine.h include/jsonparser/stage4_shovel_machine.h
|
||||
LIBFILES=src/jsonioutil.cpp src/jsonparser.cpp src/stage1_find_marks.cpp src/stage2_flatten.cpp src/stage3_ape_machine.cpp src/stage4_shovel_machine.cpp
|
||||
MINIFIERHEADERS=include/jsonparser/jsonminifier.h include/jsonparser/simdprune_tables.h
|
||||
|
@ -22,7 +23,7 @@ RAPIDJSON_INCLUDE:=dependencies/rapidjson/include
|
|||
|
||||
LIBS=$(RAPIDJSON_INCLUDE) $(LIBDOUBLE)
|
||||
|
||||
all: $(LIBS) $(EXECUTABLES)
|
||||
all: $(LIBS) $(EXECUTABLES) $(DOUBLEEXECUTABLES)
|
||||
|
||||
test: jsoncheck
|
||||
./jsoncheck
|
||||
|
@ -51,6 +52,15 @@ minifiercompetition: benchmark/minifiercompetition.cpp $(HEADERS) $(MINIFIERHEAD
|
|||
parsingcompetition: benchmark/parsingcompetition.cpp $(HEADERS) $(LIBFILES)
|
||||
$(CXX) $(CXXFLAGS) -o parsingcompetition $(LIBFILES) benchmark/parsingcompetition.cpp -I. $(LIBFLAGS)
|
||||
|
||||
parsedouble: benchmark/parse.cpp $(HEADERS) $(LIBFILES)
|
||||
$(CXX) $(CXXFLAGS) -o parsedouble $(LIBFILES) benchmark/parse.cpp $(LIBFLAGS) -DDOUBLECONV
|
||||
|
||||
jsoncheckdouble:tests/jsoncheck.cpp $(HEADERS) $(LIBFILES)
|
||||
$(CXX) $(CXXFLAGS) -o jsoncheckdouble $(LIBFILES) tests/jsoncheck.cpp -I. $(LIBFLAGS) -DDOUBLECONV
|
||||
|
||||
parsingcompetitiondouble: benchmark/parsingcompetition.cpp $(HEADERS) $(LIBFILES)
|
||||
$(CXX) $(CXXFLAGS) -o parsingcompetitiondouble $(LIBFILES) benchmark/parsingcompetition.cpp -I. $(LIBFLAGS) -DDOUBLECONV
|
||||
|
||||
|
||||
parsehisto: benchmark/parse.cpp $(HEADERS) $(LIBFILES)
|
||||
$(CXX) $(CXXFLAGS) -o parsehisto benchmark/parse.cpp $(LIBFILES) $(LIBFLAGS) -DBUILDHISTOGRAM
|
||||
|
|
|
@ -249,6 +249,9 @@ really_inline bool parse_string(const u8 *buf, UNUSED size_t len,
|
|||
}
|
||||
|
||||
#ifdef DOUBLECONV
|
||||
#include "double-conversion/double-conversion.h"
|
||||
#include "double-conversion/ieee.h"
|
||||
using namespace double_conversion;
|
||||
static StringToDoubleConverter
|
||||
converter(StringToDoubleConverter::ALLOW_TRAILING_JUNK, 2000000.0,
|
||||
Double::NaN(), NULL, NULL);
|
||||
|
@ -277,8 +280,13 @@ really_inline bool parse_number(const u8 *buf, UNUSED size_t len,
|
|||
int processed_characters_count;
|
||||
double result_double_conv = converter.StringToDouble(
|
||||
(const char *)(buf + offset), 10, &processed_characters_count);
|
||||
printf("number is %f and used %d chars \n", result_double_conv,
|
||||
processed_characters_count);
|
||||
*((double *)pj.current_number_buf_loc) = result_double_conv;
|
||||
pj.tape[tape_loc] =
|
||||
((u32)'d') << 24 |
|
||||
(pj.current_number_buf_loc -
|
||||
pj.number_buf); // assume 2^24 will hold all numbers for now
|
||||
pj.current_number_buf_loc += 8;
|
||||
return result_double_conv == result_double_conv;
|
||||
#endif
|
||||
////////////////
|
||||
// end of double conv temporary stuff.
|
||||
|
|
Loading…
Reference in New Issue