Bladeren bron

Addressed ULib

msmith-techempower 11 jaren geleden
bovenliggende
commit
45a9d80669

+ 1 - 1
frameworks/C++/ULib/benchmark_config

@@ -24,7 +24,7 @@
       "versus": ""
     },
     "mysql": {
-      "setup_file": "setup",
+      "setup_file": "setup-mysql",
       "json_url": "/json",
       "db_url": "/db",
       "query_url": "/query?queries=",

+ 11 - 0
frameworks/C++/ULib/setup-mysql.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+export UMEMPOOL="135,0,0,34,8465,129,-17,-22,41"
+export ORM_DRIVER="mysql"
+export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=hello_world"
+
+# 1. Change ULib Server configuration
+sed -i 's|PREFORK_CHILD .*|PREFORK_CHILD '"${MAX_THREADS}"'|g' $ULIB_ROOT/benchmark.cfg
+
+# 2. Start ULib Server (userver_tcp)
+$ULIB_ROOT/bin/userver_tcp -c $ULIB_ROOT/benchmark.cfg

+ 0 - 48
frameworks/C++/ULib/setup.py

@@ -1,48 +0,0 @@
-import os
-import sys
-import time
-import setup_util
-import subprocess
-import multiprocessing
-
-def get_env_for_database(args):
-  if args.database == 'MySQL':
-     driver = 'mysql'
-     dbname = 'hello_world'
-  else:
-     driver = 'sqlite'
-     dbname = os.environ['ULIB_ROOT'] + '/db/%.*s'
-  return {
-      'UMEMPOOL': '135,0,0,34,8465,129,-17,-22,41',
-      'ORM_DRIVER': driver,
-      'ORM_OPTION': "host=" + args.database_host + " user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=" + dbname
-    }
-
-def start(args, logfile, errfile):
-  try:
-    ulib_root = os.environ['ULIB_ROOT']
-    fcfg = ulib_root + "/benchmark.cfg"
-    fprg = ulib_root + "/bin/userver_tcp"
-    # 1. Change ULib Server configuration
-    setup_util.replace_text(fcfg, "PREFORK_CHILD .*", "PREFORK_CHILD " + str(multiprocessing.cpu_count()))
-    # 2. Start ULib Server (userver_tcp)
-    subprocess.Popen( "%s -c %s" % (fprg, fcfg), shell=True, stdout=logfile, stderr=errfile, env = get_env_for_database(args))
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-
-def stop(logfile, errfile):
-  try:
-    # Stop ULib Server (userver_tcp)
-    subprocess.check_call("kill -TERM $( cat $ULIB_ROOT/userver_tcp.pid )", shell=True, stderr=errfile, stdout=logfile)
-    time.sleep(3);
-    p = subprocess.Popen(['pgrep', 'userver_tcp'], stdout=subprocess.PIPE)
-    out, err = p.communicate()
-    for line in out.splitlines():
-       if 'userver_tcp' in line:
-         pid = int(line.split(None, 2)[1])
-         os.kill(pid, 9)
-    subprocess.call("rm -f $ULIB_ROOT/userver_tcp.pid", shell=True, stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1

+ 14 - 0
frameworks/C++/ULib/setup.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+export UMEMPOOL="135,0,0,34,8465,129,-17,-22,41"
+echo $UMEMPOOL
+export ORM_DRIVER="sqlite"
+echo $ORM_DRIVER
+export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=${ULIB_ROOT}/db/%.*s"
+echo $ORM_OPTION
+
+# 1. Change ULib Server configuration
+sed -i 's|PREFORK_CHILD .*|PREFORK_CHILD '"${MAX_THREADS}"'|g' $ULIB_ROOT/benchmark.cfg
+
+# 2. Start ULib Server (userver_tcp)
+$ULIB_ROOT/bin/userver_tcp -c $ULIB_ROOT/benchmark.cfg

+ 0 - 38
frameworks/C++/treefrog/setup.py

@@ -1,38 +0,0 @@
-
-import subprocess
-import sys
-import setup_util
-from os.path import expanduser
-
-home = expanduser("~")
-
-##############
-# start(args)
-##############
-def start(args, logfile, errfile):
-  setup_util.replace_text("treefrog/config/database.ini", "HostName=.*", "HostName=" + args.database_host)
-  setup_util.replace_text("treefrog/config/application.ini", "MultiProcessingModule=.*", "MultiProcessingModule=hybrid")
-
-  # 1. Generate Makefile
-  # 2. Compile applicaton
-  # 3. Clean log files
-  # 4. Start TreeFrog
-  try:
-    subprocess.check_call("qmake -r CONFIG+=release", shell=True, cwd="treefrog", stderr=errfile, stdout=logfile)
-    subprocess.check_call("make clean", shell=True, cwd="treefrog", stderr=errfile, stdout=logfile)
-    subprocess.check_call("make -j8", shell=True, cwd="treefrog", stderr=errfile, stdout=logfile)
-    subprocess.check_call("rm -f log/*.log", shell=True, cwd="treefrog", stderr=errfile, stdout=logfile)
-    subprocess.check_call("treefrog -d $TROOT", shell=True, stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-
-##############
-# stop()
-##############
-def stop(logfile, errfile):
-  try:
-    subprocess.call("treefrog -k abort $TROOT", shell=True, stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1