#!/usr/bin/env python import sys import os import time from multiprocessing.managers import BaseManager import numpy as np import interp.bootstrap import logging log = logging.getLogger("interp") class QueueManager(BaseManager): pass QueueManager.register('get_inqueue' ) QueueManager.register('get_outqueue') def run_queries(count, order = 3, extra_points = 8): r = [] submit_start = time.time() for i in xrange(count): X = np.random.random((1,3))[0] inq.put((i,order,extra_points,X)) submit_end = time.time() receive_start = time.time() for i in xrange(count): r.append(outq.get()) receive_end = time.time() return (r, submit_end - submit_start, receive_end - receive_start) if __name__ == '__main__': server = 'localhost' m = QueueManager(address=(server, 50000), authkey='asdf') m.connect() expected_participants, count = (int(i) for i in sys.argv[1:]) inq = m.get_inqueue() outq = m.get_outqueue() # wait for all participants to be loaded up for i in xrange(expected_participants): print outq.get() # run codes results, submit, receive = run_queries(count, order=3, extra_points = 64) # shut down all participants for i in xrange(expected_participants): inq.put([None] * 4) stats = {} stats['submit' ] = float(submit) stats['receive' ] = float(receive) stats['count' ] = count stats['expected_participants'] = expected_participants print "submit time for %(count)s interps, %(expected_participants)d participants: %(submit)0.2f seconds, results time: %(receive)0.2f" % stats log.error("stats: %s", stats)