]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fullbench: switch default generator to lorem ipsum
authorYann Collet <yann.collet.73@gmail.com>
Sat, 14 Dec 2024 20:34:26 +0000 (12:34 -0800)
committerYann Collet <cyan@fb.com>
Fri, 20 Dec 2024 18:36:59 +0000 (10:36 -0800)
which creates more "realistic" scenarios than former compressible noise.

The legacy data generator remains accessible,
it is triggered when requesting an explicit compressibility factor (-P#).

tests/Makefile
tests/fullbench.c

index 74e05774c41f431d3cb5faee93e3db9cabe942d8..c10d66f53dcd2602ace56e7c198d62d8adb9f3d1 100644 (file)
@@ -150,12 +150,12 @@ $(FULLBENCHS) : LDFLAGS += $(MULTITHREAD_LD)
 $(FULLBENCHS) : DEBUGFLAGS = -DNDEBUG  # turn off assert() for speed measurements
 $(FULLBENCHS) : DEBUGLEVEL = 0  # turn off assert() for speed measurements
 $(FULLBENCHS) : $(ZSTD_FILES)
-$(FULLBENCHS) : $(PRGDIR)/datagen.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/benchfn.c fullbench.c
+$(FULLBENCHS) : $(PRGDIR)/datagen.c $(PRGDIR)/lorem.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/benchfn.c fullbench.c
        $(LINK.c) $^ -o $@$(EXT)
 
 CLEAN += fullbench-lib
 fullbench-lib : CPPFLAGS += -DXXH_NAMESPACE=ZSTD_
-fullbench-lib : $(PRGDIR)/datagen.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/benchfn.c $(LIB_SRCDIR)/libzstd.a fullbench.c
+fullbench-lib : $(PRGDIR)/datagen.c $(PRGDIR)/lorem.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/benchfn.c $(LIB_SRCDIR)/libzstd.a fullbench.c
        $(LINK.c) $^ -o $@$(EXT)
 
 # note : broken : requires symbols unavailable from dynamic library
index ff512149a9a87a79c695020707a647e647c0aa28..889761ef4e680f8b888925cbf4ed1022f559bfa4 100644 (file)
@@ -33,6 +33,7 @@
 #include "zstd.h"        /* ZSTD_versionString */
 #include "util.h"        /* time functions */
 #include "datagen.h"
+#include "lorem.h"
 #include "benchfn.h"     /* CustomBench */
 #include "benchzstd.h"   /* MB_UNIT */
 
@@ -50,7 +51,7 @@
 
 #define DEFAULT_CLEVEL 1
 
-#define COMPRESSIBILITY_DEFAULT 0.50
+#define COMPRESSIBILITY_DEFAULT (-1.0)
 static const size_t kSampleSizeDefault = 10000000;
 
 #define TIMELOOP_NANOSEC      (1*1000000000ULL) /* 1 second */
@@ -754,6 +755,11 @@ _cleanOut:
 
 
 #define BENCH_ALL_SCENARIOS 999
+/*
+ * if @compressibility < 0.0, use Lorem Ipsum generator
+ * otherwise, @compressibility is expected to be between 0.0 and 1.0
+ * if scenarioID == BENCH_ALL_SCENARIOS, all scenarios will be run on the sample
+*/
 static int benchSample(U32 scenarioID,
                        size_t benchedSize, double compressibility,
                        int cLevel, ZSTD_compressionParameters cparams)
@@ -763,7 +769,12 @@ static int benchSample(U32 scenarioID,
     if (!origBuff) { DISPLAY("\nError: not enough memory!\n"); return 12; }
 
     /* Fill buffer */
-    RDG_genBuffer(origBuff, benchedSize, compressibility, 0.0, 0);
+    if (compressibility < 0.0) {
+        LOREM_genBuffer(origBuff, benchedSize, 0);
+    } else {
+        RDG_genBuffer(origBuff, benchedSize, compressibility, 0.0, 0);
+
+    }
 
     /* bench */
     DISPLAY("\r%70s\r", "");