Skip to content

Commit

Permalink
test: fix benchmark.py and set up to run under github if requested
Browse files Browse the repository at this point in the history
Add the word "benchmark" to the comment to get the benchmarking code
to run.
  • Loading branch information
rouilj committed Apr 10, 2024
1 parent db40abb commit f6f29af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ jobs:
# -f scripts/Docker/Dockerfile .


- name: run benchmarks
if: "contains(github.event.head_commit.message, 'benchmark')"
run: PYTHONPATH=. python test/benchmark.py

# in parallel build coveralls requires a finish step
finish:
needs: test
Expand Down
18 changes: 10 additions & 8 deletions test/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import print_function
import sys, os, time
import importlib

from roundup.hyperdb import String, Password, Link, Multilink, Date, \
Interval, DatabaseError, Boolean, Number
from roundup import date, password

from .db_test_base import config
from test.db_test_base import config

def setupSchema(db, module):
status = module.Class(db, "status", name=String())
Expand All @@ -25,7 +26,8 @@ def setupSchema(db, module):

def main(backendname, time=time.time, numissues=10):
try:
exec('from roundup.backends import %s as backend'%backendname)
backend = importlib.import_module("roundup.backends.back_%s" %
backendname)
except ImportError:
return

Expand All @@ -37,14 +39,14 @@ def main(backendname, time=time.time, numissues=10):
db = backend.Database(config, 'admin')
setupSchema(db, backend)
# create a whole bunch of stuff
db.user.create(**{'username': 'admin'})
db.user.create(**{'username': 'admin', 'roles': 'Admin'})
db.status.create(name="unread")
db.status.create(name="in-progress")
db.status.create(name="testing")
db.status.create(name="resolved")
pc = -1
for i in range(numissues):
db.user.create(**{'username': 'user %s'%i})
db.user.create(**{'username': 'user %s'%i, 'roles': 'User'})
for j in range(10):
db.user.set(str(i+1), assignable=1)
db.user.set(str(i+1), assignable=0)
Expand Down Expand Up @@ -122,14 +124,14 @@ def main(backendname, time=time.time, numissues=10):
# 0 1 2 3 4 5 6
# 01234567890123456789012345678901234567890123456789012345678901234
print('Test name fetch journl jprops lookup filter filtml TOTAL ')
for name in 'anydbm metakit sqlite'.split():
for name in 'anydbm sqlite'.split():
main(name)
for name in 'anydbm metakit sqlite'.split():
for name in 'anydbm sqlite'.split():
main(name, numissues=20)
for name in 'anydbm metakit sqlite'.split():
for name in 'anydbm sqlite'.split():
main(name, numissues=100)
# don't even bother benchmarking the dbm backends > 100!
for name in 'metakit sqlite'.split():
for name in 'sqlite'.split():
main(name, numissues=1000)

# vim: set et sts=4 sw=4 :

0 comments on commit f6f29af

Please sign in to comment.