MCPcopy Index your code
hub / github.com/python/cpython / test_compress_shared_dict

Method test_compress_shared_dict

Lib/test/test_zstd.py:2747–2772  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2745 @threading_helper.reap_threads
2746 @threading_helper.requires_working_threading()
2747 def test_compress_shared_dict(self):
2748 num_threads = 8
2749
2750 def run_method(b):
2751 level = threading.get_ident() % 4
2752 # sync threads to increase chance of contention on
2753 # capsule storing dictionary levels
2754 b.wait()
2755 ZstdCompressor(level=level,
2756 zstd_dict=TRAINED_DICT.as_digested_dict)
2757 b.wait()
2758 ZstdCompressor(level=level,
2759 zstd_dict=TRAINED_DICT.as_undigested_dict)
2760 b.wait()
2761 ZstdCompressor(level=level,
2762 zstd_dict=TRAINED_DICT.as_prefix)
2763 threads = []
2764
2765 b = threading.Barrier(num_threads)
2766 for i in range(num_threads):
2767 thread = threading.Thread(target=run_method, args=(b,))
2768
2769 threads.append(thread)
2770
2771 with threading_helper.start_threads(threads):
2772 pass
2773
2774 @threading_helper.reap_threads
2775 @threading_helper.requires_working_threading()

Callers

nothing calls this directly

Calls 2

BarrierMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected