diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/README | 31 | ||||
-rw-r--r-- | test/performanceTests.py | 9 |
2 files changed, 35 insertions, 5 deletions
diff --git a/test/README b/test/README new file mode 100644 index 000000000..647875251 --- /dev/null +++ b/test/README @@ -0,0 +1,31 @@ +The test directory contains some unit and performance tests for Scintilla. + +The tests can only be run on Windows using Python 3.x. Running on another platform +would require writing a file similar to XiteWin.py for that platform. Python 3.x is required +because its default string type is Unicode and earlier Python versions use byte strings +and the interface to the platform assumes a particular string type. + +A test application is in xite.py and this can be run to experiment: +pythonw xite.py + +To run the basic tests: +pythonw simpleTests.py + +There are some lexing tests with simple input files in several languages in the examples +subdirectory and their expected lexed states in *.styled where the start of each style +is marked with {styleNumber}, for example: +{15}<%@{16}language=javas{15}%>{0} + +To run the lexing tests: +pythonw lexTests.py + +To check for performance regressions: +pythonw performanceTests.py +While each test run will be different and the timer has only limited granularity, some results +from a 2 GHz Athlon with a DEBUG build are: + 0.187 testAddLine +. 0.203 testAddLineMiddle +. 0.171 testHuge +. 0.203 testHugeInserts +. 0.312 testHugeReplace +. diff --git a/test/performanceTests.py b/test/performanceTests.py index ed0550558..9dd1a9c17 100644 --- a/test/performanceTests.py +++ b/test/performanceTests.py @@ -17,7 +17,7 @@ class TestPerformance(unittest.TestCase): def testAddLine(self): data = (string.ascii_letters + string.digits + "\n").encode('utf-8') start = time.time() - for i in range(500): + for i in range(1000): self.ed.AddText(len(data), data) self.assertEquals(self.ed.LineCount, i + 2) end = time.time() @@ -29,7 +29,7 @@ class TestPerformance(unittest.TestCase): def testAddLineMiddle(self): data = (string.ascii_letters + string.digits + "\n").encode('utf-8') start = time.time() - for i in range(500): + for i in range(1000): self.ed.AddText(len(data), data) self.assertEquals(self.ed.LineCount, i + 2) end = time.time() @@ -41,7 +41,6 @@ class TestPerformance(unittest.TestCase): def testHuge(self): data = (string.ascii_letters + string.digits + "\n").encode('utf-8') data = data * 100000 - print("len is", len(data)) start = time.time() self.ed.AddText(len(data), data) end = time.time() @@ -56,7 +55,7 @@ class TestPerformance(unittest.TestCase): insert = (string.digits + "\n").encode('utf-8') self.ed.AddText(len(data), data) start = time.time() - for i in range(500): + for i in range(1000): self.ed.InsertText(0, insert) end = time.time() duration = end - start @@ -70,7 +69,7 @@ class TestPerformance(unittest.TestCase): insert = (string.digits + "\n").encode('utf-8') self.ed.AddText(len(data), data) start = time.time() - for i in range(500): + for i in range(1000): self.ed.TargetStart = i * len(insert) self.ed.TargetEnd = self.ed.TargetStart + len(oneLine) self.ed.ReplaceTarget(len(insert), insert) |