Last active
May 4, 2023 09:29
-
-
Save lk-geimfari/99c5b45906be5299a3088f42c3f55bf4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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