def __init__(self, config):
		self.config = config		
		self.newly_created_user_ids = []				

		# if the user has specified batch size option then use it or use the default list
		if options.batch_size != None:
			self.default_benchmark_user_batch_size = [options.batch_size]
		else:
		    self.default_benchmark_user_batch_size = [1, 5, 10, 50, 100, 500]
			
		#setup the organization for tests by adding required topics and alternate
		self.setup = BenchmarkSetup(self.config)		
class InsertUpdateDeleteBenchmark(object):
	def __init__(self, config):
		self.config = config		
		self.newly_created_user_ids = []				

		# if the user has specified batch size option then use it or use the default list
		if options.batch_size != None:
			self.default_benchmark_user_batch_size = [options.batch_size]
		else:
		    self.default_benchmark_user_batch_size = [1, 5, 10, 50, 100, 500]
			
		#setup the organization for tests by adding required topics and alternate
		self.setup = BenchmarkSetup(self.config)		
		
	def batch_add_recipients(self, del_users=True):
		"""
		   returns the time required to add a batch of recipients in the inEnterprise system
		"""
		# clear the entire list to remove any values from previous run_benchmark
		del self.newly_created_user_ids[:]
		
		r = Recipient(self.config, self.batch_size)
		elapsed_time = r.create_batch()
		self.newly_created_user_ids = r.get_user_ids()
		if del_users:
			self.delete_newly_created_users()
		return elapsed_time

	def update_newly_created_recipients(self):
		update_recipients = UpdateRecipient(self.config, self.batch_size)
		users_to_be_updated = list(self.newly_created_user_ids)
		elapsed_time = update_recipients.update(users_to_be_updated)
		return elapsed_time

	def batch_update_recipients(self):
		self.batch_add_recipients(False)		
		elapsed_time = self.update_newly_created_recipients()		
		self.delete_newly_created_users()
		return elapsed_time

	def delete_newly_created_users(self):
		delete_time=0		
		if len(self.newly_created_user_ids) > 0:
			delRep = DeleteRecipient(self.config, self.batch_size)
			delete_time = delRep.delete(self.newly_created_user_ids)
			# clear the entire list
			del self.newly_created_user_ids[:]
		else:
			pass
		return delete_time

	def batch_delete_recipients(self):
		self.batch_add_recipients(False)
		return self.delete_newly_created_users()

	def benchmark_inserts(self):
		self.benchmark('Add', self.batch_add_recipients)

	def benchmark_updates(self):
		self.benchmark('Update', self.batch_update_recipients)
		
	def benchmark_deletes(self):
		self.benchmark('Delete', self.batch_delete_recipients)

	def benchmark(self, benchmark_op, batch_fun):		
		for self.batch_size in self.default_benchmark_user_batch_size:			
			run_benchmark('%s a batch of recipients with batch size %d'%(benchmark_op,  self.batch_size), batch_fun, options.iterations, options)
		
	def clean_up(self):
		self.setup.clean_up()