Browse Source

Merge branch 'python-update' of https://github.com/methane/FrameworkBenchmarks into methane-python-update

Patrick Falls 12 years ago
parent
commit
3d928a9225
9 changed files with 91 additions and 12 deletions
  1. 19 1
      flask/README.md
  2. 8 1
      flask/app.py
  3. 8 0
      flask/benchmark_config
  4. 14 0
      flask/run_pypy.py
  5. 21 0
      flask/setup_pypy.py
  6. 5 0
      framework_test.py
  7. 15 8
      installer.py
  8. 1 1
      run-tests.py
  9. 0 1
      tornado/setup.py

+ 19 - 1
flask/README.md

@@ -2,6 +2,24 @@
 
 Single file test, [app.py](app.py)
 
+## Description
+
+Flask + Flask-SQLAlchemy
+
+### Interpreter
+
+* CPython 2.7.4
+* PyPy 2.0
+
+### Database
+
+MySQL (MySQL-python on CPython, PyMySQL on PyPy)
+
+### Server
+
+* gunicorn+meinheld on CPython
+* Tornado on PyPy
+
 
 ## Test URLs
 ### JSON Encoding 
@@ -22,4 +40,4 @@ With ORM:
     http://localhost:8080/db?queries=2
 
 Without ORM (raw):
-    http://localhost:8080/dbraw?queries=2
+    http://localhost:8080/dbraw?queries=2

+ 8 - 1
flask/app.py

@@ -3,8 +3,15 @@ from flask.ext.sqlalchemy import SQLAlchemy
 from sqlalchemy import create_engine
 from random import randint
 
+try:
+    import MySQLdb
+    mysql_schema = "mysql:"
+except ImportError:
+    mysql_schema = "mysql+pymysql:"
+
+
 app = Flask(__name__)
-app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://benchmarkdbuser:benchmarkdbpass@DBHOSTNAME:3306/hello_world'
+app.config['SQLALCHEMY_DATABASE_URI'] = mysql_schema + '//benchmarkdbuser:benchmarkdbpass@DBHOSTNAME:3306/hello_world'
 db = SQLAlchemy(app)
 dbraw_engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])
 

+ 8 - 0
flask/benchmark_config

@@ -15,6 +15,14 @@
       "query_url": "/dbraw?queries=",
       "port": 8080,
       "sort": 84
+    },
+    "pypy": {
+      "setup_file": "setup_pypy",
+      "json_url": "/json",
+      "db_url": "/dbs",
+      "query_url": "/db?queries=",
+      "port": 8080,
+      "sort": 107
     }
   }]
 }

+ 14 - 0
flask/run_pypy.py

@@ -0,0 +1,14 @@
+import tornado.options
+import tornado.wsgi
+import tornado.httpserver
+from tornado.options import options
+
+tornado.options.define('port', default=8080, type=int, help=("Server port"))
+tornado.options.parse_command_line()
+
+import app
+container = tornado.wsgi.WSGIContainer(app.app)
+server = tornado.httpserver.HTTPServer(container)
+server.bind(options.port)
+server.start(8)
+tornado.ioloop.IOLoop.instance().start()

+ 21 - 0
flask/setup_pypy.py

@@ -0,0 +1,21 @@
+import subprocess
+import sys
+import setup_util
+import os
+
+proc = None
+
+def start(args):
+  global proc
+  setup_util.replace_text("flask/app.py", "DBHOSTNAME", args.database_host)
+  proc = subprocess.Popen("~/FrameworkBenchmarks/installs/pypy-2.0/bin/pypy run_pypy.py --port=8080 --logging=error", shell=True, cwd="flask")
+  return 0
+
+def stop():
+  global proc
+  if not proc:
+    return 0
+  proc.terminate()
+  ret = proc.wait()
+  proc = None
+  return ret

+ 5 - 0
framework_test.py

@@ -201,6 +201,7 @@ class FrameworkTest:
     try:
       if self.json_url_passed and (self.benchmarker.type == "all" or self.benchmarker.type == "json"):
         sys.stdout.write("BENCHMARKING JSON ... ") 
+        sys.stdout.flush()
         remote_script = self.__generate_concurrency_script(self.json_url, self.port)
         self.__run_benchmark(remote_script, self.benchmarker.output_file(self.name, 'json'))
         results = self.__parse_test('json')
@@ -214,6 +215,7 @@ class FrameworkTest:
     try:
       if self.db_url_passed and (self.benchmarker.type == "all" or self.benchmarker.type == "db"):
         sys.stdout.write("BENCHMARKING DB ... ") 
+        sys.stdout.flush()
         remote_script = self.__generate_concurrency_script(self.db_url, self.port)
         self.__run_benchmark(remote_script, self.benchmarker.output_file(self.name, 'db'))
         results = self.__parse_test('db')
@@ -227,6 +229,7 @@ class FrameworkTest:
     try:
       if self.query_url_passed and (self.benchmarker.type == "all" or self.benchmarker.type == "query"):
         sys.stdout.write("BENCHMARKING Query ... ") 
+        sys.stdout.flush()
         remote_script = self.__generate_query_script(self.query_url, self.port)
         self.__run_benchmark(remote_script, self.benchmarker.output_file(self.name, 'query'))
         results = self.__parse_test('query')
@@ -239,6 +242,7 @@ class FrameworkTest:
     try:
       if self.fortune_url_passed and (self.benchmarker.type == "all" or self.benchmarker.type == "fortune"):
         sys.stdout.write("BENCHMARKING Fortune ... ") 
+        sys.stdout.flush()
         remote_script = self.__generate_concurrency_script(self.fortune_url, self.port)
         self.__run_benchmark(remote_script, self.benchmarker.output_file(self.name, 'fortune'))
         results = self.__parse_test('fortune')
@@ -251,6 +255,7 @@ class FrameworkTest:
     try:
       if self.update_url_passed and (self.benchmarker.type == "all" or self.benchmarker.type == "update"):
         sys.stdout.write("BENCHMARKING Update ... ") 
+        sys.stdout.flush()
         remote_script = self.__generate_query_script(self.update_url, self.port)
         self.__run_benchmark(remote_script, self.benchmarker.output_file(self.name, 'update'))
         results = self.__parse_test('update')

+ 15 - 8
installer.py

@@ -46,13 +46,18 @@ class Installer:
     # Python
     #
 
-    self.__run_command("curl http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz | tar xvz")
-    self.__run_command("./configure", cwd="Python-2.7.3")
-    self.__run_command("sudo make install", cwd="Python-2.7.3")
-    self.__run_command("curl http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz | tar xvz")
-    self.__run_command("sudo python setup.py install", cwd="setuptools-0.6c11")
-    self.__run_command("curl http://pypi.python.org/packages/source/p/pip/pip-1.1.tar.gz | tar xvz")
-    self.__run_command("sudo python setup.py install", cwd="pip-1.1")
+    self.__run_command("curl -L http://bitbucket.org/pypy/pypy/downloads/pypy-2.0-linux64.tar.bz2 | tar xvj")
+    self.__run_command("curl http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tgz | tar xvz")
+    self.__run_command("./configure", cwd="Python-2.7.4")
+    self.__run_command("make -j", cwd="Python-2.7.4")
+    self.__run_command("sudo make install", cwd="Python-2.7.4")
+    self.__run_command("curl https://pypi.python.org/packages/source/d/distribute/distribute-0.6.38.tar.gz | tar xvz")
+    # run pypy before python. (`setup.py install` fails after `sudo setup.py install`)
+    self.__run_command("../pypy-2.0/bin/pypy setup.py install", cwd="distribute-0.6.38")
+    self.__run_command("sudo python setup.py install", cwd="distribute-0.6.38")
+    self.__run_command("curl https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz | tar xvz")
+    self.__run_command("../pypy-2.0/bin/pypy setup.py install", cwd="pip-1.3.1")
+    self.__run_command("sudo python setup.py install", cwd="pip-1.3.1")
     self.__run_command("sudo pip install MySQL-python==1.2.4")
     self.__run_command("sudo pip install simplejson==3.0.7")
     self.__run_command("curl http://initd.org/psycopg/tarballs/PSYCOPG-2-5/psycopg2-2.5.tar.gz | tar xvz")
@@ -60,6 +65,8 @@ class Installer:
     self.__run_command("git clone https://github.com/iiilx/django-psycopg2-pool.git")
     self.__run_command("sudo python setup.py install", cwd="django-psycopg2-pool")
     self.__run_command("sudo pip install --upgrade numpy==1.7.1")
+    self.__run_command("sudo pip install --upgrade tornado motor Flask Flask-SQLAlchemy meinheld gunicorn")
+    self.__run_command("pypy-2.0/bin/pip install --upgrade tornado motor Flask Flask-SQLAlchemy PyMySQL")
 
     #
     # nodejs
@@ -396,7 +403,7 @@ class Installer:
     ##############################
     # MongoDB
     ##############################
-    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
+    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
     sudo cp 10gen.list /etc/apt/sources.list.d/10gen.list
     sudo apt-get update
     yes | sudo apt-get install mongodb-10gen

+ 1 - 1
run-tests.py

@@ -17,7 +17,7 @@ parser.add_argument('-d', '--database-host')
 parser.add_argument('-i', dest='identity_file', help='ssh key to ssh from the server instance to the client instance.')
 parser.add_argument('-p', dest='password_prompt', action='store_true')
 parser.add_argument('--install-software', action='store_true', help='runs the installation script before running the rest of the commands')
-parser.add_argument('--install', choices=['clinet', 'server', 'all'], default='all', help='Allows you to only install the server or client software')
+parser.add_argument('--install', choices=['client', 'server', 'all'], default='all', help='Allows you to only install the server or client software')
 parser.add_argument('--test', nargs='+', help='names of tests to run')
 parser.add_argument('--exclude', nargs='+', help='names of tests to exclude')
 parser.add_argument('--type', choices=['all', 'json', 'db', 'query', 'fortune', 'update'], default='all', help='which type of test to run')

+ 0 - 1
tornado/setup.py

@@ -12,7 +12,6 @@ def start(args):
     setup_util.replace_text(
         cwd + "/server.py", "localhost", args.database_host)
 
-    subprocess.check_call("sudo pip install -r requirements.txt", cwd=cwd, shell=True)
     subprocess.Popen("python %s/FrameworkBenchmarks/tornado/server.py --port=8080 --logging=error" % home, shell=True, cwd=cwd)
     return 0