Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,18 @@ When using a PEP 517 builder you can use ``ZSTD_WARNINGS`` environment variable

>>> $ ZSTD_WARNINGS=1 python -m build -w

If you want to treat all warnings as errors just add ``--
all-warnings-errors`` option
If you want to treat all warnings as errors just add ``--all-warnings-errors`` option

>>> $ python setup.py build_ext --all-warnings-errors clean

When using a PEP 517 builder you can use ``ZSTD_WERRORS`` environment variable instead:

>>> $ ZSTD_WERRORS=1 python -m build -w

When using a PEP 517 builder you can use ``ZSTD_FULLTIME_TESTS`` environment variable, to run tests with fulltime length:

>>> $ ZSTD_FULLTIME_TESTS=1 python setup.py test

Install from pypi
-----------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def which(bin_exe):
}
if BUILD_SPEED3:
COPT = {
'msvc': ['/O3', ],
'msvc': ['/Ox', ],
'mingw32': ['-O3',],
'unix': ['-O3',],
'clang': ['-O3',],
Expand Down
12 changes: 9 additions & 3 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ extern "C" {
typedef struct stat stat_t;
#endif

static int numLogicalCores = 1;
static time_t lastTimeCached = 0;
static int util_cpuCoresCacheTTL = 60;
#if defined(_WIN32) || defined(WIN32)
static int numLogicalCores = 1;
static time_t lastTimeCached = 0;
static int util_cpuCoresCacheTTL = 60;
#else
__attribute__((unused)) static int numLogicalCores = 1;
__attribute__((unused)) static time_t lastTimeCached = 0;
__attribute__((unused)) static int util_cpuCoresCacheTTL = 60;
#endif
int UTIL_countAvailableCores(void);
int UTIL_setCpuCoresCacheTTL(int cacheTTL);
int UTIL_stopCpuCoresCache(void);
Expand Down
64 changes: 53 additions & 11 deletions tests/test_speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def test_00_system_info(self):
log.info("Bundled libzstd uses threads? :%r" % zstd.ZSTD_with_threads())

def test_compression_speed(self):
wait = 30
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 30
log.info("\nWait %d seconds..." % wait)
sum = 0
l=len(tDATA)
Expand All @@ -28,8 +30,30 @@ def test_compression_speed(self):
log.info("Compression speed average = %6.2f Mb/sec" % (1.0*sum/1024/1024/wait,))
log.info("diff Compression memory usage = %6.2f kb" % (1.0*(endMemoryUsage-beginMemoryUsage)/1024,))

def test_compression_speed_no_cpu_cores_cache(self):
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 30
log.info("\nWait %d seconds..." % wait)
sum = 0
l=len(tDATA)
tbegin = time()
beginMemoryUsage=get_real_memory_usage()
log.info("begin Compression memory usage = %6.2f kb" % (1.0*beginMemoryUsage/1024,))
zstd.ZSTD_stopCpuCoresCache()
while time()-tbegin<wait:
cdata = zstd.compress(tDATA,3,0)
sum+=l

endMemoryUsage=get_real_memory_usage()
log.info("end Compression memory usage = %6.2f kb" % (1.0*endMemoryUsage/1024,))
log.info("Compression speed average = %6.2f Mb/sec" % (1.0*sum/1024/1024/wait,))
log.info("diff Compression memory usage = %6.2f kb" % (1.0*(endMemoryUsage-beginMemoryUsage)/1024,))

def test_compression_one_thread_speed(self):
wait = 30
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 30
log.info("\nWait %d seconds..." % wait)
sum = 0
l=len(tDATA)
Expand All @@ -46,7 +70,9 @@ def test_compression_one_thread_speed(self):
log.info("diff Compression with one thread memory usage = %6.2f kb" % (1.0*(endMemoryUsage-beginMemoryUsage)/1024,))

def test_decompression_block_speed(self):
wait = 30
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 30
log.info("\nWait %d seconds..." % wait)
sum = 0
cdata = zstd.compress(tDATA)
Expand All @@ -59,7 +85,9 @@ def test_decompression_block_speed(self):
log.info("Decompression of block data speed average = %6.2f Mb/sec" % (1.0*sum/1024/1024/wait,))

def test_decompression_stream_speed(self):
wait = 30
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 30
log.info("\nWait %d seconds..." % wait)
sum = 0
# cdata = zstd.compress(tDATA)
Expand All @@ -82,7 +110,9 @@ def test_decompression_stream_speed(self):


def test_check_speed(self):
wait = 30
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 30
log.info("\nWait %d seconds..." % wait)
sum = 0
cdata = zstd.compress(tDATA)
Expand All @@ -100,7 +130,9 @@ def test_check_speed(self):
log.info("diff Check memory usage = %6.2f kb" % (1.0*(endMemoryUsage-beginMemoryUsage)/1024,))

def test_cpu_cores_cache_default_speed(self):
wait = 70
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 70
log.info("\nWait %d seconds..." % wait)
ops = 0
tbegin = time()
Expand All @@ -116,7 +148,9 @@ def test_cpu_cores_cache_default_speed(self):
log.info("diff Check memory usage = %6.2f kb" % (1.0*(endMemoryUsage-beginMemoryUsage)/1024,))

def test_cpu_cores_cache_none_speed(self):
wait = 70
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 70
log.info("\nWait %d seconds..." % wait)
ops = 0
tbegin = time()
Expand All @@ -133,7 +167,9 @@ def test_cpu_cores_cache_none_speed(self):
log.info("diff Check memory usage = %6.2f kb" % (1.0*(endMemoryUsage-beginMemoryUsage)/1024,))

def test_cpu_cores_cache_60_speed(self):
wait = 70
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 70
log.info("\nWait %d seconds..." % wait)
ops = 0
tbegin = time()
Expand All @@ -149,7 +185,9 @@ def test_cpu_cores_cache_60_speed(self):
log.info("diff Check memory usage = %6.2f kb" % (1.0*(endMemoryUsage-beginMemoryUsage)/1024,))

def test_cpu_cores_cache_01_speed(self):
wait = 70
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 70
log.info("\nWait %d seconds..." % wait)
ops = 0
tbegin = time()
Expand All @@ -166,7 +204,9 @@ def test_cpu_cores_cache_01_speed(self):
log.info("diff Check memory usage = %6.2f kb" % (1.0*(endMemoryUsage-beginMemoryUsage)/1024,))

def test_cpu_cores_cache_05_speed(self):
wait = 70
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 70
log.info("\nWait %d seconds..." % wait)
ops = 0
tbegin = time()
Expand All @@ -183,7 +223,9 @@ def test_cpu_cores_cache_05_speed(self):
log.info("diff Check memory usage = %6.2f kb" % (1.0*(endMemoryUsage-beginMemoryUsage)/1024,))

def test_cpu_cores_cache_10_speed(self):
wait = 70
wait = 10
if "ZSTD_FULLTIME_TESTS" in os.environ:
wait = 70
log.info("\nWait %d seconds..." % wait)
ops = 0
tbegin = time()
Expand Down
Loading