def insertion_delete_performance(self,file_name,safe_mode): try: json_array = get_json(file_name) indx = 0 time_serial = [] start_time = time.time() #caculate the start time for row in json_array[:1000000]: indx += 1 repost = Repost( _id=MAX_ID+indx, city="", created_at=date.today(), favourites_count=10, statuses_count=10, friends_count=row.get("friends_count",""), gender="m", location="beijing", sm_user_id=1, profile_image_url="", province="need to delete", retweet_status_created_at=date.today(), user_id=1, retweet_status_source="", screen_name="", retweet_status_text=row.get("retweet_status_text", ""), post_id=10, verified=False, sm_flash_factor=1, sm_user_followers_count=1, retweet_status_id=1, sm_user_screen_name="", source="", followers_count=row.get("followers_count", ""), text=row.get("text",""), user_created_at=date.today() ) repost.save(safe=safe_mode, force_insert=True) if indx%10000 == 0: time_serial.append(time.time() - start_time) print time.time() - start_time return time_serial except IOError: print "open file failed" return
def find_performance_engine(self, times): ''' size is the number of lines will be updated, safe_mode is a way to update the fields, its value is True or False ''' try: start_time = time.time() indx = 0 time_serial = [] while indx< 100: indx += 1 Repost.objects( _id__lt=MAX_ID+indx*10000, _id__gt=MAX_ID+(indx-1)*10000 ).count() time_serial.append(time.time() - start_time) print time_serial return time_serial except IOError: print 'error' return