Skip to content

Instantly share code, notes, and snippets.

@lk-geimfari
Last active May 4, 2023 09:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lk-geimfari/99c5b45906be5299a3088f42c3f55bf4 to your computer and use it in GitHub Desktop.
import cProfile
from mimesis import Person
from mimesis.locales import Locale
from faker import Faker
person = Person(Locale.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