Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions ULib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#ULib Benchmarking Test

This is the ULib portion of a [benchmarking test suite](https://github.com/TechEmpower/FrameworkBenchmarks) comparing a variety of web development platforms.

### JSON Encoding Test

* [JSON test source](src/json.usp)

### Data-Store/Database Mapping Test

* [Database test source](src/db.usp)

### Variable Query Test

* [Variable Query test source](src/queries.usp)

### Fortune Query Test

* [Fortune Query test source](src/fortunes.usp)

### Variable Query (update) Test

* [Variable Query (update) test source](src/updates.usp)

### Plaintext Test

* [Plaintext test source](src/plaintext.usp)

## Infrastructure Software Versions
The tests were run with:

* [ULib Version 1.4.1](https://github.com/stefanocasazza/ULib/archive/v1.4.1.tar.gz)

Output
======

[/json](http://www.techempower.com/benchmarks/#section=json)
-----
```
HTTP/1.1 200 OK
Date: Thu, 03 Jul 2014 10:11:10 GMT
Server: ULib
Content-Length: 27
Content-Type: application/json; charset=UTF-8

{"message":"Hello, World!"}
```

[/db](http://www.techempower.com/benchmarks/#section=db)
---
```
HTTP/1.1 200 OK
Date: Thu, 03 Jul 2014 10:14:51 GMT
Server: ULib
Content-Length: 31
Content-Type: application/json; charset=UTF-8

{"id":6227,"randomNumber":8489}
```

[/queries?queries=10](http://www.techempower.com/benchmarks/#section=query)
-------------------
```
HTTP/1.1 200 OK
Date: Thu, 03 Jul 2014 10:14:51 GMT
Server: ULib
Content-Length: 320
Content-Type: application/json; charset=UTF-8

[{"id":6851,"randomNumber":7598},{"id":3968,"randomNumber":7325},{"id":8159,"randomNumber":348},{"id":9560,"randomNumber":7333},{"id":9938,"randomNumber":9080},{"id":1598,"randomNumber":1623},{"id":3280,"randomNumber":8707},{"id":4521,"randomNumber":6063},{"id":8173,"randomNumber":3690},{"id":3648,"randomNumber":8803}]
```

[/fortunes](http://www.techempower.com/benchmarks/#section=fortune)
---------
```
HTTP/1.1 200 OK
Date: Thu, 03 Jul 2014 10:14:51 GMT
Server: ULib
Content-Type: text/html; charset=UTF-8
Content-Length: 1111

<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><tr><td>11</td><td>&lt;script&gt;alert("This should not be displayed in a browser alert box.");&lt;/script&gt;</td></tr><tr><td>4</td><td>A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1</td></tr><tr><td>5</td><td>A computer program does what you tell it to do, not what you want it to do.</td></tr><tr><td>2</td><td>A computer scientist is someone who fixes things that aren't broken.</td></tr><tr><td>8</td><td>A list is only as strong as its weakest link. � Donald Knuth</td></tr><tr><td>3</td><td>After enough decimal places, nobody gives a damn.</td></tr><tr><td>7</td><td>Any program that runs right is obsolete.</td></tr><tr><td>10</td><td>Computers make very fast, very accurate mistakes.</td></tr><tr><td>6</td><td>Emacs is a nice operating system, but I prefer UNIX. � Tom Christaensen</td></tr><tr><td>9</td><td>Feature: A bug with seniority.</td></tr><tr><td>1</td><td>fortune: No such file or directory</td></tr><tr><td>12</td><td>�?�?�?�?�?�?�?�?�?�?�?�?�?�?</td></tr></table></body></html>
```

[/updates?queries=10](http://www.techempower.com/benchmarks/#section=update)
-------------------
```
HTTP/1.1 200 OK
Date: Thu, 03 Jul 2014 10:14:51 GMT
Server: ULib
Content-Length: 319
Content-Type: application/json; charset=UTF-8

[{"id":7171,"randomNumber":351},{"id":6019,"randomNumber":9725},{"id":8118,"randomNumber":4023},{"id":7965,"randomNumber":1388},{"id":7797,"randomNumber":2249},{"id":112,"randomNumber":1108},{"id":6127,"randomNumber":4323},{"id":2597,"randomNumber":7509},{"id":2978,"randomNumber":7883},{"id":1111,"randomNumber":2228}]
```

[/plaintext](http://www.techempower.com/benchmarks/#section=plaintext)
----------
```
HTTP/1.1 200 OK
Date: Thu, 03 Jul 2014 10:14:51 GMT
Server: ULib
Content-Type: text/plain; charset=UTF-8
Content-Length: 13

Hello, World!
```
Empty file added ULib/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions ULib/bash_profile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
if [ -z "${FWROOT}" ]; then
export FWROOT=${HOME}/FrameworkBenchmarks
fi
#------------------------------------------------------------ --------------------------------------------
# IROOT - Path of this test's install directory ($FWROOT/installs or $FWROOT/installs/pertest/<test-name>)
#------------------------------------------------------------ --------------------------------------------
if [ -z "${IROOT}" ]; then
export IROOT=${FWROOT}/installs
fi

# Set the root of our ULib installation
export ULIB_ROOT=${IROOT}/ULib

# Where to find the userver_tcp executable
export PATH="${ULIB_ROOT}/bin:$PATH"

export ULIB_VERSION=1.4.1
export ULIB_DOCUMENT_ROOT=${ULIB_ROOT}/ULIB_DOCUMENT_ROOT
export ULIB_BUILD_OUTPUT=${ULIB_ROOT}/ULIB_BUILD_OUTPUT.txt
export ULIB_SERVER_OUTPUT=${ULIB_ROOT}/ULIB_SERVER_OUTPUT.txt
28 changes: 28 additions & 0 deletions ULib/benchmark_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"framework": "ULib",
"tests": [{
"default": {
"setup_file": "setup",
"json_url": "/json",
"db_url": "/db",
"query_url": "/queries?queries=",
"fortune_url": "/fortunes",
"update_url": "/updates?queries=",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"database": "MySQL",
"framework": "ULib",
"language": "C++",
"orm": "Micro",
"platform": "ULib",
"webserver": "None",
"os": "Linux",
"database_os": "Linux",
"display_name": "ULib",
"notes": "",
"versus": ""
}
}]
}
59 changes: 59 additions & 0 deletions ULib/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

#----------------------------------------------------------------------------------------------------
# toolset/run-tests.py --install server --install-strategy pertest --name ULib --test ULib --type all
#----------------------------------------------------------------------------------------------------

source ${HOME}/FrameworkBenchmarks/ULib/bash_profile.sh

cat <<EOF >${ULIB_ROOT}/benchmark.cfg
userver {
PORT 8080
PREFORK_CHILD 8
LISTEN_BACKLOG 16384
MAX_KEEP_ALIVE 16384
DOCUMENT_ROOT ${ULIB_DOCUMENT_ROOT}
PID_FILE ${ULIB_ROOT}/userver_tcp.pid
}
EOF

RET1=$(fw_exists ${ULIB_ROOT}/bin/userver_tcp)
RET2=$(fw_exists ${ULIB_DOCUMENT_ROOT}/db.so)

if [ "$RET1" == 0 ] && [ "$RET2" == 0 ]; then
return 0;
fi

# 1. Download ULib
wget -nc --no-check-certificate --trust-server-names -O v${ULIB_VERSION}.tar.gz https://github.com/stefanocasazza/ULib/archive/v${ULIB_VERSION}.tar.gz

# 2. Compile application (userver_tcp)
fw_untar v${ULIB_VERSION}.tar.gz

cd ULib-$ULIB_VERSION
# ======================================================================================================
# TO AVOID configure: error: newly created file is older than distributed files! Check your system clock
# ======================================================================================================
find . -exec touch {} \;
# ======================================================================================================

LIBS="-lssl -lcrypto -lz" \
./configure --prefix=$ULIB_ROOT \
--disable-static \
--with-mysql \
--without-ssl --without-pcre --without-expat \
--without-libz --without-libuuid --without-magic \
--enable-static-orm-driver=mysql --enable-static-server-plugin=http >$ULIB_BUILD_OUTPUT 2>&1

make -j1 install >>$ULIB_BUILD_OUTPUT 2>&1

# 3. Compile usp pages for benchmark
cd src/ulib/net/server/plugin/usp
make -j1 db.la fortunes.la json.la plaintext.la queries.la updates.la >>$ULIB_BUILD_OUTPUT 2>&1

if [ ! -e .libs/db.so ]; then
return 1;
fi

mkdir -p $ULIB_DOCUMENT_ROOT
cp .libs/db.so .libs/fortunes.so .libs/json.so .libs/plaintext.so .libs/queries.so .libs/updates.so $ULIB_DOCUMENT_ROOT
88 changes: 88 additions & 0 deletions ULib/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# -------------------------------------------------------
# toolset/run-tests.py --name ULib --test ULib --type all
# -------------------------------------------------------
import os
import sys
import time
#import logging
import setup_util
import subprocess
import multiprocessing

#log = logging.getLogger('framework_test')

subprocess.call("source ${HOME}/FrameworkBenchmarks/ULib/bash_profile.sh", shell=True, executable='/bin/bash')

ulib_root = subprocess.check_output('printf "$ULIB_ROOT" 2>/dev/null', shell=True, executable='/bin/bash')
ulib_document_root = subprocess.check_output('printf "$ULIB_DOCUMENT_ROOT" 2>/dev/null', shell=True, executable='/bin/bash')

fcfg = ulib_root + "/benchmark.cfg"
fprg = ulib_root + "/bin/userver_tcp"
fusp = ulib_document_root + "/db.so"

script = """
if [ -x "${ULIB_ROOT}/bin/userver_tcp" ] && [ -e "${ULIB_DOCUMENT_ROOT}/db.so" ] && [ -f "${ULIB_ROOT}/benchmark.cfg" ]; then
return 0;
fi
return 1;
"""

p = subprocess.Popen(['sh'], stdin=subprocess.PIPE)
p.communicate(script)
if p.returncode != 0:
# log.critical('ULib install script FAILED')
print('ULib install script FAILED')
if not os.path.exists(fprg):
# log.critical("ULib server program " + fprg + " NOT EXIST")
print("ULib server program " + fprg + " NOT EXIST")
if not os.path.exists(fusp):
# log.critical("ULib usp page " + fusp + " NOT EXIST")
print("ULib usp page " + fusp + " NOT EXIST")
if not os.path.exists(fcfg):
# log.critical("ULib configuration file " + fcfg + " NOT EXIST")
print("ULib configuration file " + fcfg + " NOT EXIST")
# log.critical('Aborting')
print('Aborting')
exit(1)

##############
# start(args)
##############
def start(args, logfile, errfile):
try:
# 1. Change ULib Server configuration
#threads = str(args.max_threads)
PROCS = str(multiprocessing.cpu_count())
setup_util.replace_text(fcfg, "PREFORK_CHILD *", "PREFORK_CHILD " + PROCS)

# 2. Start ULib Server (userver_tcp)
# log.info("trying to start ULib server " + fprg + " -c " + fcfg)
print("trying to start ULib server " + fprg + " -c " + fcfg)

os.putenv("ORM_DRIVER","mysql")
os.putenv("ORM_OPTION","host=" + args.database_host + " user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world")
os.putenv("UMEMPOOL", "1583,1507,-19,45,16458,523,-27,-14,27")

# Run in the background, but keep stdout/stderr for easy debugging
subprocess.Popen(fprg + " -c " + fcfg + " >$ULIB_SERVER_OUTPUT 2>&1", shell=True, stdout=logfile, stderr=errfile)
return 0
except subprocess.CalledProcessError:
return 1

##############
# stop()
##############
def stop(logfile, errfile):
try:
# Stop ULib Server (userver_tcp)
subprocess.check_call("kill -TERM $( cat " + iroot + "/userver_tcp.pid )", shell=True, stderr=errfile, stdout=logfile)
time.sleep(2);
p = subprocess.Popen(['ps', 'aux'], 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)
return 0
except subprocess.CalledProcessError:
return 1
8 changes: 8 additions & 0 deletions ULib/source_code
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
./src/db.usp
./src/world.h
./src/json.usp
./src/fortune.h
./src/queries.usp
./src/updates.usp
./src/fortunes.usp
./src/plaintext.usp
Loading