* 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:
parent
9385212033
commit
a2a230411a
@ -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>
|
2005-12-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||||
* src/GrampsBSDDB.py: added work around for cursor set not
|
* src/GrampsBSDDB.py: added work around for cursor set not
|
||||||
returing None.
|
returing None.
|
||||||
|
@ -1027,8 +1027,8 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
|||||||
return
|
return
|
||||||
transaction.set_description(msg)
|
transaction.set_description(msg)
|
||||||
self.undoindex += 1
|
self.undoindex += 1
|
||||||
if self.undoindex == _UNDO_SIZE:
|
if self.undoindex >= _UNDO_SIZE:
|
||||||
self.translist = transaction[0:-1] + [ transaction ]
|
self.translist = self.translist[0:-1] + [ transaction ]
|
||||||
else:
|
else:
|
||||||
self.translist[self.undoindex] = transaction
|
self.translist[self.undoindex] = transaction
|
||||||
|
|
||||||
|
@ -4,10 +4,16 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.append('../src')
|
sys.path.append('../src')
|
||||||
|
|
||||||
|
try:
|
||||||
|
set()
|
||||||
|
except NameError:
|
||||||
|
from set import Set as set
|
||||||
|
|
||||||
import GrampsBSDDB
|
import GrampsBSDDB
|
||||||
import RelLib
|
import RelLib
|
||||||
|
|
||||||
@ -24,6 +30,7 @@ class ReferenceMapTest (unittest.TestCase):
|
|||||||
None, # callback
|
None, # callback
|
||||||
"w")
|
"w")
|
||||||
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
shutil.rmtree(self._tmpdir)
|
shutil.rmtree(self._tmpdir)
|
||||||
|
|
||||||
@ -60,7 +67,12 @@ class ReferenceMapTest (unittest.TestCase):
|
|||||||
lnk_sources.add(sources[source_idx-1])
|
lnk_sources.add(sources[source_idx-1])
|
||||||
source_idx = (source_idx+1) % len(sources)
|
source_idx = (source_idx+1) % len(sources)
|
||||||
|
|
||||||
|
try:
|
||||||
add_func(lnk_sources)
|
add_func(lnk_sources)
|
||||||
|
except:
|
||||||
|
print "person_idx = ", person_idx
|
||||||
|
print "lnk_sources = ", repr(lnk_sources)
|
||||||
|
raise
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -199,15 +211,23 @@ class ReferenceMapTest (unittest.TestCase):
|
|||||||
|
|
||||||
return end - start
|
return end - start
|
||||||
|
|
||||||
def test_performance(self):
|
def perf_simple_search_speed(self):
|
||||||
|
|
||||||
self._populate_database(num_sources = 100,
|
num_sources = 100
|
||||||
num_persons = 80,
|
num_persons = 1000
|
||||||
num_families = 10,
|
num_families = 10
|
||||||
num_events = 10,
|
num_events = 10
|
||||||
num_places = 10,
|
num_places = 10
|
||||||
num_media_objects = 10,
|
num_media_objects = 10
|
||||||
num_links = 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
|
# 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
|
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("with refs %s\n", str(with_reference_map))
|
||||||
logger.info("without refs %s\n", str(without_reference_map))
|
logger.info("without refs %s\n", str(without_reference_map))
|
||||||
|
|
||||||
@ -241,5 +275,8 @@ class ReferenceMapTest (unittest.TestCase):
|
|||||||
def testSuite():
|
def testSuite():
|
||||||
return unittest.makeSuite(ReferenceMapTest,'test')
|
return unittest.makeSuite(ReferenceMapTest,'test')
|
||||||
|
|
||||||
|
def perfSuite():
|
||||||
|
return unittest.makeSuite(ReferenceMapTest,'perf')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.TextTestRunner().run(testSuite())
|
unittest.TextTestRunner().run(testSuite())
|
||||||
|
@ -13,6 +13,8 @@ def make_parser():
|
|||||||
parser = OptionParser(usage)
|
parser = OptionParser(usage)
|
||||||
parser.add_option("-v", "--verbosity", type="int", dest="verbose_level", default=0,
|
parser.add_option("-v", "--verbosity", type="int", dest="verbose_level", default=0,
|
||||||
help="Level of verboseness")
|
help="Level of verboseness")
|
||||||
|
parser.add_option("-p", "--performance", action="store_true", dest="performance", default=False,
|
||||||
|
help="Run the performance tests.")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -21,14 +23,22 @@ def getTestSuites():
|
|||||||
test_modules = [ i for i in os.listdir('.') if i[-8:] == "_Test.py" ]
|
test_modules = [ i for i in os.listdir('.') if i[-8:] == "_Test.py" ]
|
||||||
|
|
||||||
test_suites = []
|
test_suites = []
|
||||||
|
perf_suites = []
|
||||||
for module in test_modules:
|
for module in test_modules:
|
||||||
mod = __import__(module[:-3])
|
mod = __import__(module[:-3])
|
||||||
test_suites.append(mod.testSuite())
|
test_suites.append(mod.testSuite())
|
||||||
|
try:
|
||||||
|
perf_suites.append(mod.perfSuite())
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
return test_suites
|
return (test_suites,perf_suites)
|
||||||
|
|
||||||
def allTheTests():
|
def allTheTests():
|
||||||
return unittest.TestSuite(getTestSuites())
|
return unittest.TestSuite(getTestSuites()[0])
|
||||||
|
|
||||||
|
def perfTests():
|
||||||
|
return unittest.TestSuite(getTestSuites()[1])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
@ -58,4 +68,8 @@ if __name__ == '__main__':
|
|||||||
logger.setLevel(logging.ERROR)
|
logger.setLevel(logging.ERROR)
|
||||||
console.setLevel(logging.ERROR)
|
console.setLevel(logging.ERROR)
|
||||||
|
|
||||||
|
|
||||||
|
if options.performance:
|
||||||
|
unittest.TextTestRunner(verbosity=options.verbose_level).run(perfTests())
|
||||||
|
else:
|
||||||
unittest.TextTestRunner(verbosity=options.verbose_level).run(allTheTests())
|
unittest.TextTestRunner(verbosity=options.verbose_level).run(allTheTests())
|
||||||
|
Loading…
Reference in New Issue
Block a user