<s> __author__ = """<STR_LIT>""" <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from os import getcwd <EOL> from os import sys <EOL> sys . path . append ( getcwd ( ) ) <EOL> from MOAL . helpers . display import Section <EOL> from MOAL . helpers . display import print_h2 <EOL> from MOAL . helpers . display import divider <EOL> from MOAL . helpers . trials import run_trials <EOL> from MOAL . helpers . trials import test_speed <EOL> from datetime import datetime as dt <EOL> from faker import Factory <EOL> import couchdb <EOL> from pprint import pprint as ppr <EOL> DEBUG = True if __name__ == '<STR_LIT:__main__>' else False <EOL> faker = Factory . create ( ) <EOL> couch = couchdb . Server ( ) <EOL> try : <EOL> test_db = couch . create ( '<STR_LIT>' ) <EOL> except couchdb . http . PreconditionFailed : <EOL> couch . delete ( '<STR_LIT>' ) <EOL> test_db = couch . create ( '<STR_LIT>' ) <EOL> def make_person ( ) : <EOL> return { <EOL> '<STR_LIT:name>' : faker . name ( ) , <EOL> '<STR_LIT:email>' : faker . email ( ) , <EOL> '<STR_LIT:address>' : faker . address ( ) , <EOL> '<STR_LIT:url>' : faker . url ( ) , <EOL> '<STR_LIT>' : str ( dt . now ( ) ) <EOL> } <EOL> @ test_speed <EOL> def insert_all ( max_records ) : <EOL> for n in range ( max_records ) : <EOL> test_db . save ( make_person ( ) ) <EOL> if DEBUG : <EOL> with Section ( '<STR_LIT>' ) : <EOL> run_trials ( insert_all , trials = <NUM_LIT:10> ) <EOL> print_h2 ( '<STR_LIT>' ) <EOL> for res in test_db : <EOL> divider ( ) <EOL> ppr ( test_db [ res ] ) </s>
