def get_saved_uuids(num_rhics):
    saved_uuids = []
    for x in range(0, num_rhics):
        identity = ConsumerIdentity(uuid=module_uuid.uuid4())
        identity.engineering_ids=["1","2","3"]
        identity.save()
        saved_uuids.append(identity.uuid)
    return saved_uuids
def create_identities(num_rhics):
    objects = []
    for x in range(0, num_rhics):
        identity = ConsumerIdentity(uuid=uuid.uuid4())
        identity.engineering_ids=[str(x)]
        objects.append(identity)
    q = ConsumerIdentity.objects()
    return q.insert(objects, safe=False, load_bulk=False)
def simulate_inserts_bulk(num_rhics):
    objects = []
    for x in range(0, num_rhics):
        identity = ConsumerIdentity(uuid=uuid.uuid4())
        objects.append(identity)
    q = ConsumerIdentity.objects()
    q.insert(objects, load_bulk=False, safe=False)
    return objects
def convert_to_raw_data(ids):
    raw_data = []
    for consumer_uuid in ids:
        obj = ConsumerIdentity.objects(uuid=consumer_uuid).first()
        d = get_single_entry(uuid=str(obj.uuid), created_date=str(obj.created_date),
                modified_date=str(obj.modified_date),
                engineering_ids=obj.engineering_ids)
        raw_data.append(d)
    return raw_data
    q = ConsumerIdentity.objects()
    q.insert(objects, load_bulk=False, safe=False)
    return objects

if __name__ == "__main__":
    parser = OptionParser(description="Test script to time update/insert of RHICs")
    parser.add_option("--num", action="store", 
            help="Number of RHICs to test with", default=10)
    (opts, args) = parser.parse_args()
    num_rhics = int(opts.num)
    init()

    start = time.time()
    simulate_inserts(num_rhics)
    end = time.time()
    count = ConsumerIdentity.objects().count()
    if count != num_rhics:
        print "Error with test, only found %s items in mongo, expected %s" % \
                (count, num_rhics)
        sys.exit(1)
    print "%s seconds to simulate insert of %s RHICs" % (end-start, num_rhics)
    clean_db()

    start = time.time()
    objects = simulate_inserts_bulk(num_rhics)
    end = time.time()
    print "%s seconds to simulate bulk insert of %s RHICs" % (end-start, num_rhics)
    clean_db()

    start = time.time()
    objects = simulate_updates(objects)