* src/GrampsDbBase.py: fixed UNDO buffer issue

* test/GrampsDbBase_Test.py: improved performance test
	* test/RunAllTests.py: added -p cmdline flag


svn: r5571
This commit is contained in:
Richard Taylor 2005-12-17 21:13:45 +00:00
parent e102387e98
commit fff5c3e595
4 changed files with 74 additions and 18 deletions

View File

@ -1,3 +1,8 @@
2005-12-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsDbBase.py: fixed UNDO buffer issue
* test/GrampsDbBase_Test.py: improved performance test
* test/RunAllTests.py: added -p cmdline flag
2005-12-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsBSDDB.py: added work around for cursor set not
returing None.

View File

@ -1027,8 +1027,8 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
return
transaction.set_description(msg)
self.undoindex += 1
if self.undoindex == _UNDO_SIZE:
self.translist = transaction[0:-1] + [ transaction ]
if self.undoindex >= _UNDO_SIZE:
self.translist = self.translist[0:-1] + [ transaction ]
else:
self.translist[self.undoindex] = transaction

View File

@ -4,10 +4,16 @@ import os
import tempfile
import shutil
import time
import traceback
import sys
sys.path.append('../src')
try:
set()
except NameError:
from set import Set as set
import GrampsBSDDB
import RelLib
@ -24,6 +30,7 @@ class ReferenceMapTest (unittest.TestCase):
None, # callback
"w")
def tearDown(self):
shutil.rmtree(self._tmpdir)
@ -60,7 +67,12 @@ class ReferenceMapTest (unittest.TestCase):
lnk_sources.add(sources[source_idx-1])
source_idx = (source_idx+1) % len(sources)
add_func(lnk_sources)
try:
add_func(lnk_sources)
except:
print "person_idx = ", person_idx
print "lnk_sources = ", repr(lnk_sources)
raise
return
@ -199,15 +211,23 @@ class ReferenceMapTest (unittest.TestCase):
return end - start
def test_performance(self):
def perf_simple_search_speed(self):
self._populate_database(num_sources = 100,
num_persons = 80,
num_families = 10,
num_events = 10,
num_places = 10,
num_media_objects = 10,
num_links = 10)
num_sources = 100
num_persons = 1000
num_families = 10
num_events = 10
num_places = 10
num_media_objects = 10
num_links = 10
self._populate_database(num_sources,
num_persons,
num_families,
num_events,
num_places,
num_media_objects,
num_links)
# time searching for source backrefs with and without reference_map
@ -233,6 +253,20 @@ class ReferenceMapTest (unittest.TestCase):
self._db.__class__.find_backlink_handles = remember
logger.info("search test with following data: \n"
"num_sources = %d \n"
"num_persons = %d \n"
"num_families = %d \n"
"num_events = %d \n"
"num_places = %d \n"
"num_media_objects = %d \n"
"num_links = %d" % (num_sources,
num_persons,
num_families,
num_events,
num_places,
num_media_objects,
num_links))
logger.info("with refs %s\n", str(with_reference_map))
logger.info("without refs %s\n", str(without_reference_map))
@ -241,5 +275,8 @@ class ReferenceMapTest (unittest.TestCase):
def testSuite():
return unittest.makeSuite(ReferenceMapTest,'test')
def perfSuite():
return unittest.makeSuite(ReferenceMapTest,'perf')
if __name__ == '__main__':
unittest.TextTestRunner().run(testSuite())

View File

@ -13,6 +13,8 @@ def make_parser():
parser = OptionParser(usage)
parser.add_option("-v", "--verbosity", type="int", dest="verbose_level", default=0,
help="Level of verboseness")
parser.add_option("-p", "--performance", action="store_true", dest="performance", default=False,
help="Run the performance tests.")
return parser
@ -21,14 +23,22 @@ def getTestSuites():
test_modules = [ i for i in os.listdir('.') if i[-8:] == "_Test.py" ]
test_suites = []
perf_suites = []
for module in test_modules:
mod = __import__(module[:-3])
test_suites.append(mod.testSuite())
try:
perf_suites.append(mod.perfSuite())
except:
pass
return test_suites
return (test_suites,perf_suites)
def allTheTests():
return unittest.TestSuite(getTestSuites())
return unittest.TestSuite(getTestSuites()[0])
def perfTests():
return unittest.TestSuite(getTestSuites()[1])
if __name__ == '__main__':
@ -58,4 +68,8 @@ if __name__ == '__main__':
logger.setLevel(logging.ERROR)
console.setLevel(logging.ERROR)
unittest.TextTestRunner(verbosity=options.verbose_level).run(allTheTests())
if options.performance:
unittest.TextTestRunner(verbosity=options.verbose_level).run(perfTests())
else:
unittest.TextTestRunner(verbosity=options.verbose_level).run(allTheTests())