def postOptions(self): VumiOptions.postOptions(self) if not self['vumigo-config']: raise usage.UsageError( "Please provide the vumigo-config parameter.") if not self['user-account-key']: raise usage.UsageError( "Please provide the user-account-key parameter.")
def postOptions(self): VumiOptions.postOptions(self) if not self['vumigo-config']: raise usage.UsageError( "Please provide the vumigo-config parameter.") if not self['user-account-key']: raise usage.UsageError( "Please provide the user-account-key parameter.") if not self['conversation-key']: raise usage.UsageError( "Please provide the conversation-key parameter.") try: hz = float(self['hz']) except (TypeError, ValueError): hz_okay = False else: hz_okay = bool(hz > 0) if not hz_okay: raise usage.UsageError("Please provide a positive float for hz") self['hz'] = hz
def postOptions(self): VumiOptions.postOptions(self) if not self['vumigo-config']: raise usage.UsageError( "Please provide the vumigo-config parameter.") if not self['user-account-key']: raise usage.UsageError( "Please provide the user-account-key parameter.") if not self['conversation-key']: raise usage.UsageError( "Please provide the conversation-key parameter.") try: hz = float(self['hz']) except (TypeError, ValueError): hz_okay = False else: hz_okay = bool(hz > 0) if not hz_okay: raise usage.UsageError( "Please provide a positive float for hz") self['hz'] = hz
def postOptions(self): VumiOptions.postOptions(self) if not self['transport-name']: raise usage.UsageError("Please provide the " "transport-name parameter.")
def run_bench(loops): opts = VumiOptions() opts.postOptions() worker_creator = WorkerCreator(opts.vumi_options) app = worker_creator.create_worker_by_class( BenchApp, { "transport_name": "dummy", "javascript": """ api.on_inbound_message = function(command) { this.request('outbound.reply_to', { content: 'reply', in_reply_to: command.msg.message_id, }, function (reply) { this.done(); }); }; """, "sandbox": { 'log': { 'cls': 'vumi.application.sandbox.LoggingResource', }, 'outbound': { 'cls': 'vumi.application.sandbox.OutboundResource', }, }, }) transport = worker_creator.create_worker_by_class( BenchTransport, { "transport_name": "dummy", }) yield transport.startService() log.msg("Waiting for transport ...") yield BenchTransport.WORKER_QUEUE.get() yield app.startService() log.msg("Waiting for worker ...") yield BenchApp.WORKER_QUEUE.get() print "Starting %d loops ..." % (loops, ) timer = Timer() for i in range(loops): with timer: transport.publish_message( content="Hi!", to_addr="+1234", from_addr="+5678", transport_type="ussd", ) reply = yield transport.message_queue.get() log.msg("Reply ID: %s" % reply['message_id']) print "Total time: %.2f" % timer.total() print "Time per message: %g" % timer.mean() print " max: %g, min: %g" % (timer.max(), timer.min()) print " loops: %d" % timer.loops() yield transport.stopService() yield app.stopService() reactor.stop()
def run_bench(loops): opts = VumiOptions() opts.postOptions() worker_creator = WorkerCreator(opts.vumi_options) app = worker_creator.create_worker_by_class(BenchApp, { "transport_name": "dummy", "javascript": """ api.on_inbound_message = function(command) { this.request('outbound.reply_to', { content: 'reply', in_reply_to: command.msg.message_id, }, function (reply) { this.done(); }); }; """, "sandbox": { 'log': { 'cls': 'vumi.application.sandbox.LoggingResource', }, 'outbound': { 'cls': 'vumi.application.sandbox.OutboundResource', }, }, }) transport = worker_creator.create_worker_by_class(BenchTransport, { "transport_name": "dummy", }) yield transport.startService() log.msg("Waiting for transport ...") yield BenchTransport.WORKER_QUEUE.get() yield app.startService() log.msg("Waiting for worker ...") yield BenchApp.WORKER_QUEUE.get() print "Starting %d loops ..." % (loops,) timer = Timer() for i in range(loops): with timer: transport.publish_message( content="Hi!", to_addr="+1234", from_addr="+5678", transport_type="ussd", ) reply = yield transport.message_queue.get() log.msg("Reply ID: %s" % reply['message_id']) print "Total time: %.2f" % timer.total() print "Time per message: %g" % timer.mean() print " max: %g, min: %g" % (timer.max(), timer.min()) print " loops: %d" % timer.loops() yield transport.stopService() yield app.stopService() reactor.stop()