def basic(topic='topic', channel='channel', count=1e6, size=10, gevent=False,
    max_in_flight=2500, profile=False):
    '''Basic benchmark'''
    if gevent:
        from gevent import monkey
        monkey.patch_all()

    # Check the types of the arguments
    count = int(count)
    size = int(size)
    max_in_flight = int(max_in_flight)

    from nsq.http import nsqd
    from nsq.reader import Reader

    print 'Publishing messages...'
    for batch in grouper(messages(count, size), 1000):
        nsqd.Client('http://localhost:4151').mpub(topic, batch)

    print 'Consuming messages'
    client = Reader(topic, channel, nsqd_tcp_addresses=['localhost:4150'],
        max_in_flight=max_in_flight)
    with closing(client):
        start = -time.time()
        if profile:
            with profiler():
                for message in islice(client, count):
                    message.fin()
        else:
            for message in islice(client, count):
                message.fin()
        start += time.time()
    print 'Finished %i messages in %fs (%5.2f messages / second)' % (
        count, start, count / start)
Basic benchmark