Beispiel #1
0
def btRank():
	SIZE = random.randrange(1000,100000)
	TARGET_INDEX = random.randrange(0,SIZE)

	# randomly generate bit-vector with SIZE
	bv = BitVector(intVal=64)
	bv = bv.gen_random_bits(SIZE)

	# class of RankSupport: make Rs, Rb, Rp tables
	rank = RankSupport(bv, SIZE)

	'''
	# print size of bitvector, superblocks, and blocks
	print("Size of bit vector is: ", rank.SIZE)
	print("Size of superblock is: ", rank.SIZE_S)
	print("Size of block is: ", rank.SIZE_B)
	print("Number of superblocks: ", rank.NUM_S)
	print("Number of blocks: ", rank.NUM_B)
	
	# print bitvector
	print(bv)
	'''

	start = time.time()
	RANK = rank.rank_indexAt(bv, TARGET_INDEX)
	end = time.time()
	timeCost = end - start
	
	# this will give the size it took to implement RANK
	bitSize = sys.getsizeof(RANK)

	return SIZE, RANK, timeCost
Beispiel #2
0
def btSelect():

	SIZE = random.randrange(1000,100000)

	# randomly generate bit-vector with SIZE
	bv = BitVector(intVal=64)
	bv = bv.gen_random_bits(SIZE)
	TARGET_RANK = random.randrange(0,bv.count_bits())

	# class of SelectSupport: make Rs, Rb, Rp tables
	select = SelectSupport(bv, SIZE)

	'''
	# print bitvector
	print(bv)
	'''

	start = time.time()
	SELECT = select.select_rankOf(bv, TARGET_RANK)
	end = time.time()
	timeCost = end - start
	bitSize = sys.getsizeof(SELECT)

	return SIZE, SELECT, timeCost