Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import cProfile
from mimesis import Person
from faker import Faker
person = Person('en')
faker = Faker('en_US')
def calculate_uniqueness(iterations, sequence):
unique_names_count = len(set(sequence))
uniqueness = round((unique_names_count / iterations) * 100, 2)
return '{} of {} ({}%) are unique'.format(unique_names_count, iterations, uniqueness)
counts = (
10_000,
100_000,
1_000_000,
)
for count in counts:
names_mimesis = [person.full_name() for _ in range(count)]
print('[Mimesis] {}'.format(calculate_uniqueness(count, names_mimesis)))
print('Generating using Mimesis:')
cProfile.run('[person.full_name() for _ in range(count)]')
names_faker = [faker.name() for _ in range(count)]
print('[Faker] {}'.format(calculate_uniqueness(count, names_faker)))
print('Generating using Faker:')
cProfile.run('[faker.name() for _ in range(count)]')
print('-----' * 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.