mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
29380ff77d
All commands / use cases that heavily rely on double to a string representation conversion, (e.g. meaning take a double-precision floating-point number like 1.5 and return a string like "1.5" ), could benefit from a performance boost by swapping snprintf(buf,len,"%.17g",value) by the equivalent [fpconv_dtoa](https://github.com/night-shift/fpconv) or any other algorithm that ensures 100% coverage of conversion. This is a well-studied topic and Projects like MongoDB. RedPanda, PyTorch leverage libraries ( fmtlib ) that use the optimized double to string conversion underneath. The positive impact can be substantial. This PR uses the grisu2 approach ( grisu explained on https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf section 5 ). test suite changes: Despite being compatible, in some cases it produces a different result from printf, and some tests had to be adjusted. one case is that `%.17g` (which means %e or %f which ever is shorter), chose to use `5000000000` instead of 5e+9, which sounds like a bug? In other cases, we changed TCL to compare numbers instead of strings to ignore minor rounding issues (`expr 0.8 == 0.79999999999999999`)
28 lines
331 B
Makefile
28 lines
331 B
Makefile
STD=
|
|
WARN= -Wall
|
|
OPT= -Os
|
|
|
|
R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS)
|
|
R_LDFLAGS= $(LDFLAGS)
|
|
DEBUG= -g
|
|
|
|
R_CC=$(CC) $(R_CFLAGS)
|
|
R_LD=$(CC) $(R_LDFLAGS)
|
|
|
|
AR= ar
|
|
ARFLAGS= rcs
|
|
|
|
libfpconv.a: fpconv_dtoa.o
|
|
$(AR) $(ARFLAGS) $@ $+
|
|
|
|
fpconv_dtoa.o: fpconv_dtoa.h fpconv_dtoa.c
|
|
|
|
.c.o:
|
|
$(R_CC) -c $<
|
|
|
|
clean:
|
|
rm -f *.o
|
|
rm -f *.a
|
|
|
|
|