def test_minmax(self): rb = RoaringBitmap(range(0, 61440)) assert rb.min() == 0 assert rb.max() == 61439 rb1 = RoaringBitmap(range(0, 61441)) assert rb1.min() == 0 assert rb1.max() == 61440 assert rb1[61440] == 61440 assert list(rb1)[61440] == 61440
def test_clamp(self, single): for name, data in single: a, b = sorted(random.sample(data, 2)) ref = set(data).intersection(range(a, b)) rb = RoaringBitmap(data).intersection(range(a, b)) rb2 = RoaringBitmap(data).clamp(a, b) assert a <= rb2.min() and rb2.max() < b, name assert ref == rb2, (name, a, b) assert rb == rb2, (name, a, b)
# block-level segment stats if args.detail_level >= 1: stats = sparkline_sizes(block_segsizes) print(f"Block {block}: segs={len(block_segsizes):<6d}" + stats) block_executed_bytes = 0 block_chunk_bytes = 0 block_contract_bytes = 0 # chunkification of the contracts executed in the block for codehash, data in dict_contracts.items(): instances = data['instances'] codesize = data['size'] bytemap: ImmutableRoaringBitmap = data['map'] #.freeze() executed_bytes = len(bytemap) max_possible_chunk = bytemap.max() // args.chunk_size chunksb = RoaringBitmap() if args.chunk_size == 1: # special case for speed chunkmap = bytemap else: for c in range(0, max_possible_chunk + 1): chunk_start = c * args.chunk_size chunk_stop = (c + 1) * args.chunk_size #chunkrange = range(chunk_start, chunk_stop) #z1 = len(bytemap.clamp(chunk_start, chunk_stop)) == 0 #fastest #z2 = bytemap.intersection_len(chunkrange) == 0 #z3 = bytemap.isdisjoint(chunkrange) #assert(z1 == z2 and z2 == z3) #chunkificator = chunkificators[c] #if not bytemap.isdisjoint(chunkificator):