Permalink
Browse files

benchmarks

  • Loading branch information...
rep committed May 3, 2011
1 parent d537a74 commit a0716e77de53669b8790849eb64c6334a66a54bd
Showing with 3,201 additions and 0 deletions.
  1. +86 −0 benchmark/elang/testcli.e
  2. +34 −0 benchmark/elang/testsrv.e
  3. +56 −0 benchmark/foolscap/client.py
  4. +19 −0 benchmark/foolscap/server.py
  5. +79 −0 benchmark/jpwrcall/Testclient1.java
  6. +91 −0 benchmark/jpwrcall/Testclient2.java
  7. +26 −0 benchmark/jpwrcall/Testsrv1.java
  8. +32 −0 benchmark/jsonrpcold/client.py
  9. +241 −0 benchmark/jsonrpcold/jsonrpc/__init__.py
  10. +62 −0 benchmark/jsonrpcold/jsonrpc/apacheServiceHandler.py
  11. +62 −0 benchmark/jsonrpcold/jsonrpc/cgihandler.py
  12. +45 −0 benchmark/jsonrpcold/jsonrpc/errors.py
  13. +34 −0 benchmark/jsonrpcold/jsonrpc/http.py
  14. +76 −0 benchmark/jsonrpcold/jsonrpc/proxy.py
  15. +91 −0 benchmark/jsonrpcold/jsonrpc/socketserver.py
  16. +10 −0 benchmark/jsonrpcold/server.py
  17. +13 −0 benchmark/omniorb/Math/__init__.py
  18. +13 −0 benchmark/omniorb/Math__POA/__init__.py
  19. +42 −0 benchmark/omniorb/client.py
  20. +9 −0 benchmark/omniorb/math.idl
  21. +79 −0 benchmark/omniorb/math_idl.py
  22. +25 −0 benchmark/omniorb/server.py
  23. +54 −0 benchmark/pwrcall/client.py
  24. +23 −0 benchmark/pwrcall/server.py
  25. +53 −0 benchmark/pwrcall_fair/client.py
  26. +23 −0 benchmark/pwrcall_fair/server.py
  27. +53 −0 benchmark/symjsonrpc/client.py
  28. +59 −0 benchmark/symjsonrpc/server.py
  29. +40 −0 benchmark/symjsonrpc/stopsrv.py
  30. +45 −0 benchmark/symjsonrpc/symmetricjsonrpc/__init__.py
  31. +141 −0 benchmark/symjsonrpc/symmetricjsonrpc/dispatcher.py
  32. +540 −0 benchmark/symjsonrpc/symmetricjsonrpc/json.py
  33. +331 −0 benchmark/symjsonrpc/symmetricjsonrpc/rpc.py
  34. +178 −0 benchmark/symjsonrpc/symmetricjsonrpc/wrappers.py
  35. 0 benchmark/thrift/gen-py/__init__.py
  36. +230 −0 benchmark/thrift/gen-py/mathbench/Math.py
  37. +1 −0 benchmark/thrift/gen-py/mathbench/__init__.py
  38. +9 −0 benchmark/thrift/gen-py/mathbench/constants.py
  39. +16 −0 benchmark/thrift/gen-py/mathbench/ttypes.py
  40. +5 −0 benchmark/thrift/math.thrift
  41. +102 −0 benchmark/thrift/remote.py
  42. +31 −0 benchmark/thrift/server.py
  43. +31 −0 benchmark/xmlrpc/client.py
  44. +11 −0 benchmark/xmlrpc/server.py
View
@@ -0,0 +1,86 @@
+#!/usr/bin/env rune
+
+pragma.syntax("0.9")
+
+# introducer.setVatIdentity(introducer.newVatIdentity())
+introducer.onTheAir()
+
+# return the object represented by the URI
+def getObjectFromURI(uri) {return introducer.sturdyFromURI(uri).getRcvr()}
+
+def makeURIFromObject(obj) :String {
+ # This implementation assumes a non-persistent single incarnation
+ def [sr, _, _] := identityMgr.makeKnown(obj)
+ #XXX not a uri if bracketed, bug, markm?
+ def bracketed := introducer.sturdyToURI(sr)
+ if (bracketed =~ `<@uri>`) {return uri}
+ return bracketed
+}
+
+def math {
+ to add(a, b) {
+ return a+b
+ }
+ to mul(a, b) {
+ return a*b
+ }
+}
+
+#println((interp.getArgs())[0])
+def <util> := <unsafe:java.util.*>
+def starttime := <util:makeDate>().getTime()
+def randm := <util:makeRandom>(starttime)
+# def ctime := <unsafe:java.lang.System.currentTimeMillis>()
+# println("time " + <sys>())
+var c := 0
+println(`$starttime $c`)
+
+def bench() {
+ def rm := getObjectFromURI((interp.getArgs())[0])
+
+ def startcall() {
+ def a := randm.nextInt()
+ def b := randm.nextInt()
+ def val := rm <- add(a, b)
+ when(val) -> {
+ if (val != a+b) {
+ println("wrong result")
+ println(val)
+ println(a+b)
+ interp.continueAtTop()
+ }
+ #println(val)
+ def ctime := <util:makeDate>().getTime()
+ c += 1
+ if (c%1000 == 0) {
+ println(`$ctime $c`)
+ }
+ if (ctime - starttime < 60000) {
+ startcall()
+ } else {
+ interp.continueAtTop()
+ }
+ }
+ }
+
+ startcall()
+ startcall()
+ startcall()
+ startcall()
+ startcall()
+ startcall()
+ startcall()
+ startcall()
+ startcall()
+ startcall()
+}
+
+bench()
+
+# bind friend := getObjectFromURI(file.getText())
+interp.blockAtTop()
+
+def endtime := <util:makeDate>().getTime()
+println(`$endtime $c`)
+
+
View
@@ -0,0 +1,34 @@
+#!/usr/bin/env rune
+
+pragma.syntax("0.9")
+
+# introducer.setVatIdentity(introducer.newVatIdentity())
+introducer.onTheAir()
+
+# return the object represented by the URI
+def getObjectFromURI(uri) {return introducer.sturdyFromURI(uri).getRcvr()}
+
+def makeURIFromObject(obj) :String {
+ # This implementation assumes a non-persistent single incarnation
+ def [sr, _, _] := identityMgr.makeKnown(obj)
+ #XXX not a uri if bracketed, bug, markm?
+ def bracketed := introducer.sturdyToURI(sr)
+ if (bracketed =~ `<@uri>`) {return uri}
+ return bracketed
+}
+
+def math {
+ to add(a, b) {
+ return a+b
+ }
+ to mul(a, b) {
+ return a*b
+ }
+}
+
+println("test")
+println(makeURIFromObject(math))
+println(interp.getArgs())
+
+# bind friend := getObjectFromURI(file.getText())
+interp.blockAtTop()
@@ -0,0 +1,56 @@
+import sys
+
+from foolscap.api import Tub
+from twisted.internet import reactor
+
+import random
+import time
+
+def randint():
+ return random.randint(2**29, 2**30)
+
+def printexception(r):
+ print 'exc:', r
+ reactor.stop()
+
+def startcall(remote):
+ a = randint()
+ b = randint()
+ d = remote.callRemote("add", a=a, b=b)
+ d.addCallback(printresult, a,b, remote)
+ d.addErrback(printexception)
+
+def printresult(res, a,b, remote):
+ global c
+ if res != a+b:
+ print 'error, res!= a+b', res, a+b
+ reactor.stop()
+
+ c += 1
+ ctime = time.time()
+
+ if c % 1000 == 0:
+ print int(ctime*1000), c
+
+ if ctime - starttime < 60.0:
+ startcall(remote)
+ else:
+ print int(ctime*1000), c
+ reactor.stop()
+
+def gotReference(remote):
+ startcall(remote)
+
+
+tub = Tub()
+tub.startService()
+d = tub.getReference(sys.argv[1])
+d.addCallbacks(gotReference, printexception)
+
+c = 0
+starttime = time.time()
+ctime = time.time()
+print int(ctime*1000), c
+
+reactor.run()
+
@@ -0,0 +1,19 @@
+from foolscap.api import Referenceable, Tub
+from twisted.internet import reactor
+
+class MathServer(Referenceable):
+ def remote_add(self, a, b):
+ return a+b
+
+myserver = MathServer()
+
+tub = Tub()
+tub.listenOn("tcp:12345") # start listening on TCP port 12345
+tub.setLocation("10.0.0.94:12345")
+
+furl = tub.registerReference(myserver, "math-service")
+print "the object is available at:", furl
+
+tub.startService()
+reactor.run()
+
@@ -0,0 +1,79 @@
+import jpwrcall.Node;
+import jpwrcall.Util;
+import jpwrcall.Promise;
+import jpwrcall.RPCConnection;
+
+import org.msgpack.MessagePackObject;
+
+import java.util.Date;
+import java.util.Random;
+
+public class Testclient1 {
+ private static int c = 0;
+ private static long stime = new Date().getTime();
+ private static Random randm = new Random(stime);
+ private static RPCConnection rc;
+ private static String ref;
+
+ private static void startcall() {
+ int a = randm.nextInt();
+ int b = randm.nextInt();
+
+ Promise p = rc.call(ref, "add", a, b);
+ p.when(new OnResult(a, b));
+ p.except(new OnError());
+ }
+
+ private static class OnResult implements Util.Callback {
+ private int a; private int b;
+ public OnResult(int a, int b) {
+ this.a = a; this.b = b;
+ }
+ public void cb(Object r) {
+ //System.out.println("on_result " + r.toString());
+ int res = ((MessagePackObject)r).asInt();
+ long now = new Date().getTime();
+ if (res != this.a+this.b) {
+ System.out.println("error, res!= a+b");
+ System.exit(0);
+ }
+ c += 1;
+ if (c % 1000 == 0) {
+ System.out.println(now + " " + c);
+ }
+
+ if (now - stime < 60000) startcall();
+ else {
+ System.out.println(now + " " + c);
+ System.exit(0);
+ }
+ //if (rm.isIntegerType())
+ //System.out.println("received result: " + rm.asInt());
+ }
+ }
+
+ private static class OnConnected implements Util.Callback {
+ public void cb(Object r) {
+ long now = new Date().getTime();
+ //System.out.println("on_connected " + r.toString());
+ System.out.println(now + " " + c);
+ rc = (RPCConnection) r;
+ startcall();
+ }
+ }
+
+ private static class OnError implements Util.Callback {
+ public void cb(Object r) {
+ System.out.println("on_error " + r.toString());
+ }
+ }
+
+ public static void main(String[] args) {
+ Node n = new Node("cert_t1.jks");
+ Promise p = n.connect(args[0], 10000);
+ ref = "mathobj";
+ p.when(new OnConnected());
+ p.except(new OnError());
+ }
+
+}
@@ -0,0 +1,91 @@
+import jpwrcall.Node;
+import jpwrcall.Util;
+import jpwrcall.Promise;
+import jpwrcall.RPCConnection;
+
+import org.msgpack.MessagePackObject;
+
+import java.util.Date;
+import java.util.Random;
+
+public class Testclient2 {
+ private static int c = 0;
+ private static long stime = new Date().getTime();
+ private static Random randm = new Random(stime);
+ private static RPCConnection rc;
+ private static String ref;
+
+ private static void startcall() {
+ int a = randm.nextInt();
+ int b = randm.nextInt();
+
+ Promise p = rc.call(ref, "add", a, b);
+ p.when(new OnResult(a, b));
+ p.except(new OnError());
+ }
+
+ private static class OnResult implements Util.Callback {
+ private int a; private int b;
+ public OnResult(int a, int b) {
+ this.a = a; this.b = b;
+ }
+ public void cb(Object r) {
+ //System.out.println("on_result " + r.toString());
+ MessagePackObject rm = (MessagePackObject)r;
+ int res = 0;
+ if (rm.isIntegerType()) res = (int) rm.intValue();
+
+ long now = new Date().getTime();
+ if (res != this.a+this.b) {
+ System.out.println("error, res!= a+b");
+ System.exit(0);
+ }
+ c += 1;
+ if (c % 1000 == 0) {
+ System.out.println(now + " " + c);
+ }
+
+ if (now - stime < 60000) startcall();
+ else {
+ System.out.println(now + " " + c);
+ System.exit(0);
+ }
+ //if (rm.isIntegerType())
+ //System.out.println("received result: " + rm.asInt());
+ }
+ }
+
+ private static class OnConnected implements Util.Callback {
+ public void cb(Object r) {
+ long now = new Date().getTime();
+ //System.out.println("on_connected " + r.toString());
+ System.out.println(now + " " + c);
+ rc = (RPCConnection) r;
+ startcall();
+ startcall();
+ startcall();
+ startcall();
+ startcall();
+ startcall();
+ startcall();
+ startcall();
+ startcall();
+ startcall();
+ }
+ }
+
+ private static class OnError implements Util.Callback {
+ public void cb(Object r) {
+ System.out.println("on_error " + r.toString());
+ }
+ }
+
+ public static void main(String[] args) {
+ Node n = new Node("cert_t1.jks");
+ Promise p = n.connect(args[0], 10000);
+ ref = "53b35736993ba47de6d530cfdf24d444";
+ p.when(new OnConnected());
+ p.except(new OnError());
+ }
+
+}
@@ -0,0 +1,26 @@
+import jpwrcall.Node;
+
+/**
+ *
+ * @author Mark Schloesser
+ */
+public class Testsrv1 {
+ private static Math m;
+
+ public static class Math {
+ public int add(int a, int b) {
+ return a+b;
+ }
+ public int mul(int a, int b) {
+ return a*b;
+ }
+ }
+
+ public static void main(String[] args) {
+ Node n = new Node("cert_t1.jks");
+ Testsrv1.m = new Math();
+ String ref = n.register_object(m, "mathobj");
+ n.listen("0.0.0.0", 10000);
+ System.out.println("Math srv ready at " + n.refurl(ref));
+ }
+}
Oops, something went wrong.

0 comments on commit a0716e7

Please sign in to comment.