annotate test/benchmark.py @ 8408:e882a5d52ae5

refactor: move RateLimitExceeded to roundup.cgi.exceptions RateLimitExceeded is an HTTP exception that raises code 429. Move it to roundup.cgi.exceptions where all the other exceptions that result in http status codes are located. Also make it inherit from HTTPException since it is one. Also add docstrings for all HTTP exceptions and order HTTPExceptions by status code. BREAKING CHANGE: if somebody is importing RateLimitExceeded they will need to change their import. I consider it unlikely anybody is using RateLimitExceeded. Detectors and extensions are unlikely to raise RateLimitExceeded. So I am leaving it out of the upgrading doc. Just doc in change log.
author John Rouillard <rouilj@ieee.org>
date Sun, 10 Aug 2025 21:27:06 -0400
parents 7a3392f1f7ac
children 9c3ec0a5c7fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
1 """ Usage: python benchmark.py ["database backend list" | backend1] [backend2]
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
2
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
3 Import the backend (anydbm, sqlite by default) and run some performance
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
4 tests. Example:
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
5
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
6 test default anypy and sqlite backends
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
7
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
8 python benchmark.py
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
9
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
10 test mysql and sqlite backends
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
11
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
12 python benchmark.py mysql sqlite
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
13
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
14 or
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
15
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
16 python benchmark.py "mysql sqlite"
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
17
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
18 test all backends
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
19
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
20 python benchmark.py anydbm mysql postgresql sqlite
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
21
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
22
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
23 """
5376
64b05e24dbd8 Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents: 2823
diff changeset
24 from __future__ import print_function
2823
d41f38de578e remove unused imports: shutil, Indexer;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2813
diff changeset
25 import sys, os, time
7872
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
26 import importlib, signal, shutil
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
27
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
28 # --- patch sys.path to make sure 'import roundup' finds correct version
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
29 import os.path as osp
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
30 thisdir = osp.dirname(osp.abspath(__file__))
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
31 rootdir = osp.dirname(thisdir)
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
32 if (osp.exists(thisdir + '/benchmark.py') and
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
33 osp.exists(rootdir + '/roundup/__init__.py')):
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
34 # the script is located inside roundup source code
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
35 sys.path.insert(0, rootdir)
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
36
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
37 from roundup.hyperdb import String, Password, Link, Multilink, Date, \
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
38 Interval, DatabaseError, Boolean, Number
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
39 from roundup import date, password
2823
d41f38de578e remove unused imports: shutil, Indexer;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2813
diff changeset
40
7871
30fcdf60da44 test: fix benchmark.py and set up to run under github if requested
John Rouillard <rouilj@ieee.org>
parents: 5400
diff changeset
41 from test.db_test_base import config
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
42
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
43 # global for the default signal hander so
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
44 # my signal handler can reset before it raises signal.
7872
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
45 int_sig_default_handler = None
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
46
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
47 def setupSchema(db, module):
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
48 status = module.Class(db, "status", name=String())
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
49 status.setkey("name")
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
50 user = module.Class(db, "user", username=String(), password=Password(),
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
51 assignable=Boolean(), age=Number(), roles=String())
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
52 user.setkey("username")
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
53 file = module.FileClass(db, "file", name=String(), type=String(),
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
54 comment=String(indexme="yes"))
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
55 issue = module.IssueClass(db, "issue", title=String(indexme="yes"),
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
56 status=Link("status"), nosy=Multilink("user"), deadline=Date(),
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
57 foo=Interval(), files=Multilink("file"), assignedto=Link('user'))
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
58 session = module.Class(db, 'session', title=String())
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
59 session.disableJournalling()
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
60 db.post_init()
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
61 db.commit()
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
62
7872
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
63 def rm_db_on_signal(sig, frame):
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
64 print("removing incomplete database %s due to interruption." %
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
65 config.DATABASE)
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
66
7872
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
67 shutil.rmtree(config.DATABASE)
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
68
7872
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
69 signal.signal(signal.SIGINT, int_sig_default_handler)
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
70 # re-raise the signal so the normal signal handling runs.
7872
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
71 signal.raise_signal(signal.SIGTERM)
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
72
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
73 def main(backendname, time=time.time, numissues=10):
7872
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
74 global int_sig_default_handler
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
75
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
76 try:
7871
30fcdf60da44 test: fix benchmark.py and set up to run under github if requested
John Rouillard <rouilj@ieee.org>
parents: 5400
diff changeset
77 backend = importlib.import_module("roundup.backends.back_%s" %
30fcdf60da44 test: fix benchmark.py and set up to run under github if requested
John Rouillard <rouilj@ieee.org>
parents: 5400
diff changeset
78 backendname)
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
79 except ImportError:
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
80 print("Unable to import %s backend." % backendname)
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
81 return
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
82
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
83 times = []
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
84
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
85 config.DATABASE = os.path.join('_benchmark', '%s-%s'%(backendname,
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
86 numissues))
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
87
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
88 config.RDBMS_NAME = "rounduptest_%s" % numissues
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
89
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
90 if not os.path.exists(config.DATABASE):
7872
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
91 int_sig_default_handler = signal.signal(signal.SIGINT, rm_db_on_signal)
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
92 db = backend.Database(config, 'admin')
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
93 setupSchema(db, backend)
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
94
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
95 # if we are re-initializing, delete any existing db
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
96 db.clear()
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
97 db.commit()
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
98
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
99 # create a whole bunch of stuff
7871
30fcdf60da44 test: fix benchmark.py and set up to run under github if requested
John Rouillard <rouilj@ieee.org>
parents: 5400
diff changeset
100 db.user.create(**{'username': 'admin', 'roles': 'Admin'})
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
101 db.status.create(name="unread")
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
102 db.status.create(name="in-progress")
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
103 db.status.create(name="testing")
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
104 db.status.create(name="resolved")
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
105 pc = -1
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
106 for i in range(numissues):
7871
30fcdf60da44 test: fix benchmark.py and set up to run under github if requested
John Rouillard <rouilj@ieee.org>
parents: 5400
diff changeset
107 db.user.create(**{'username': 'user %s'%i, 'roles': 'User'})
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
108 for j in range(10):
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
109 db.user.set(str(i+1), assignable=1)
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
110 db.user.set(str(i+1), assignable=0)
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
111 db.issue.create(**{'title': 'issue %s'%i})
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
112 for j in range(10):
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
113 db.issue.set(str(i+1), status='2', assignedto='2', nosy=[])
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
114 db.issue.set(str(i+1), status='1', assignedto='1',
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
115 nosy=['1','2'])
7872
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
116 if (i*100//numissues) != pc and 'INCI' not in os.environ:
5400
2120f77554d5 Python 3 preparation: use // and __truediv__ as needed.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5388
diff changeset
117 pc = (i*100//numissues)
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
118 sys.stdout.write("%d%%\r"%pc)
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
119 sys.stdout.flush()
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
120 db.commit()
7872
163d2c60fdf3 test: benchmark no progress when INCI defined; set path; signal handling
John Rouillard <rouilj@ieee.org>
parents: 7871
diff changeset
121 signal.signal(signal.SIGINT, int_sig_default_handler)
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
122 else:
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
123 db = backend.Database(config, 'admin')
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
124 setupSchema(db, backend)
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
125
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
126 sys.stdout.write('%10s: %-6d'%(backendname[:10], numissues))
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
127 sys.stdout.flush()
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
128
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
129 times.append(('start', time()))
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
130
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
131 # fetch
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
132 db.clearCache()
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
133 for i in db.issue.list():
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
134 db.issue.get(i, 'title')
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
135 times.append(('fetch', time()))
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
136
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
137 # journals
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
138 db.clearCache()
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
139 for i in db.issue.list():
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
140 db.issue.history(i)
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
141 times.append(('journal', time()))
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
142
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
143 # "calculated" props
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
144 db.clearCache()
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
145 for i in db.issue.list():
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
146 db.issue.get(i, 'activity')
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
147 db.issue.get(i, 'creator')
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
148 db.issue.get(i, 'creation')
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
149 times.append(('jprops', time()))
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
150
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
151 # lookup
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
152 db.clearCache()
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
153 for i in range(numissues):
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
154 db.user.lookup('user %s'%i)
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
155 times.append(('lookup', time()))
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
156
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
157 # filter
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
158 db.clearCache()
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
159 for i in range(100):
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
160 db.issue.filter(None, {'assignedto': '1', 'title':'issue'},
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
161 ('+', 'activity'), ('+', 'status'))
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
162 times.append(('filter', time()))
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
163
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
164 # filter with multilink
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
165 db.clearCache()
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
166 for i in range(100):
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
167 db.issue.filter(None, {'nosy': ['1'], 'assignedto': '1',
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
168 'title':'issue'}, ('+', 'activity'), ('+', 'status'))
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
169 times.append(('filtml', time()))
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
170
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
171 # results
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
172 last = None
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
173 for event, stamp in times:
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
174 if last is None:
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
175 first = stamp
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
176 else:
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
177 sys.stdout.write(' %-6.2f'%(stamp-last))
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
178 last = stamp
5376
64b05e24dbd8 Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents: 2823
diff changeset
179 print(' %-6.2f'%(last-first))
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
180 sys.stdout.flush()
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
181
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
182 if __name__ == '__main__':
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
183 if len(sys.argv) == 2:
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
184 test_databases = sys.argv[1].split()
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
185 elif len(sys.argv) > 2:
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
186 test_databases = sys.argv[1:]
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
187 else:
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
188 test_databases = ['anydbm', 'sqlite']
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
189
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
190 # 0 1 2 3 4 5 6
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
191 # 01234567890123456789012345678901234567890123456789012345678901234
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
192 print('Test name fetch journl jprops lookup filter filtml TOTAL ')
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
193 for name in test_databases:
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
194 main(name)
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
195 for name in test_databases:
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
196 main(name, numissues=20)
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
197 for name in test_databases:
1181
49aebf5a8691 some speedups, some fixes to the benchmarking
Richard Jones <richard@users.sourceforge.net>
parents: 1174
diff changeset
198 main(name, numissues=100)
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
199
1233
69bf0d381fd7 Zope Collector fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 1181
diff changeset
200 # don't even bother benchmarking the dbm backends > 100!
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
201 try:
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
202 test_databases.remove('anydbm')
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
203 except ValueError:
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
204 # anydbm not present; this is fine
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
205 pass
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
206
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
207 for name in test_databases:
1233
69bf0d381fd7 Zope Collector fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 1181
diff changeset
208 main(name, numissues=1000)
1174
8e318dfaf479 Verify contents of tracker module when the tracker is opened
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
209
7876
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
210 for name in test_databases:
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
211 main(name, numissues=10000)
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
212
7a3392f1f7ac test: update benchmark add basic CLI support for backend arguments
John Rouillard <rouilj@ieee.org>
parents: 7873
diff changeset
213
2813
91d4d28c4a86 remove bsddb, bsddb3 backends;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 1233
diff changeset
214 # vim: set et sts=4 sw=4 :

Roundup Issue Tracker: http://roundup-tracker.org/