notepad-plus-plus/scintilla/test/performanceTests.py
Christian Grasser dcc7e600c7 Updated to Scintilla 5.4.1 & Lexilla 5.3.0
Scintilla 5.4.1
https://www.scintilla.org/scintilla541.zip
Released 27 December 2023.

1.  Add IDocumentEditable interface to allow efficient interaction with document objects which may not be visible in a Scintilla instance. This feature is provisonal and may change before being declared stable. For better type-safety, the ScintillaCall C++ API uses IDocumentEditable* where void* was used before which may require changes to client code that uses document pointer APIs DocPointer, SetDocPointer, CreateDocument, AddRefDocument, and ReleaseDocument.
2.  Ctrl-click on a selection deselects it in multiple selection mode.
3.  Add SCI_SELECTIONFROMPOINT for modifying multiple selections.
4.  Add SCI_SETMOVEEXTENDSSELECTION and SCI_CHANGESELECTIONMODE to simplify selection mode manipulation.
5.  Improve performance of global replace by reducing cache invalidation overhead. [Feature #1502](https://sourceforge.net/p/scintilla/feature-requests/1502/).
6.  Fix regular expression search for "\<" matching beginning of search when not beginning of word and for "\>" not matching line end. [Bug #2157](https://sourceforge.net/p/scintilla/bugs/2157/).
7.  Fix regular expression search failure when search for "\<" followed by search for "\>". [Bug #2413](https://sourceforge.net/p/scintilla/bugs/2413/).
8.  Fix regular expression assertion (^, $, \b. \B) failures when using SCFIND_CXX11REGEX. [Bug #2405](https://sourceforge.net/p/scintilla/bugs/2405/).
9.  Fix regular expression bug in reverse direction where shortened match returned. [Bug #2405](https://sourceforge.net/p/scintilla/bugs/2405/).
10. Avoid character fragments in regular expression search results. [Bug #2405](https://sourceforge.net/p/scintilla/bugs/2405/).
11. With a document that does not have the SC_DOCUMENTOPTION_TEXT_LARGE option set, allocating more than 2G (calling SCI_ALLOCATE or similar) will now fail with SC_STATUS_FAILURE.
12. Protect SCI_REPLACETARGET, SCI_REPLACETARGETMINIMAL, and SCI_REPLACETARGETRE from application changing target in notification handlers. [Bug #2289](https://sourceforge.net/p/scintilla/bugs/2289/).

Lexilla 5.3.0
https://www.scintilla.org/lexilla530.zip
Released 27 December 2023.

1. Fix calling AddStaticLexerModule by defining as C++ instead of C which matches header. [Bug #2421](https://sourceforge.net/p/scintilla/bugs/2421/).
2. Bash: Fix shift operator << incorrectly recognized as here-doc. [Issue #215](https://github.com/ScintillaOrg/lexilla/issues/215).
3. Bash: Fix termination of '${' with first unquoted '}' instead of nesting. [Issue #216](https://github.com/ScintillaOrg/lexilla/issues/216).
4. HTML: JavaScript double-quoted strings may escape line end with '\'. [Issue #214](https://github.com/ScintillaOrg/lexilla/issues/214).
5. Lua: recognize --- doc comments. Defined by [LDoc](https://github.com/lunarmodules/ldoc). Does not recognize --[[-- doc comments which seem less common.

Close #14375
2023-12-26 23:17:53 +01:00

150 lines
4.6 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Requires Python 2.7 or later
from __future__ import with_statement
from __future__ import unicode_literals
import string, time, unittest
try:
start = time.perf_counter()
timer = time.perf_counter
except AttributeError:
timer = time.time
import XiteWin as Xite
class TestPerformance(unittest.TestCase):
def setUp(self):
self.xite = Xite.xiteFrame
self.ed = self.xite.ed
self.ed.ClearAll()
self.ed.EmptyUndoBuffer()
def testAddLine(self):
data = (string.ascii_letters + string.digits + "\n").encode('utf-8')
start = timer()
for i in range(2000):
self.ed.AddText(len(data), data)
self.assertEqual(self.ed.LineCount, i + 2)
end = timer()
duration = end - start
print("%6.3f testAddLine" % duration)
self.xite.DoEvents()
self.assertTrue(self.ed.Length > 0)
def testAddLineMiddle(self):
data = (string.ascii_letters + string.digits + "\n").encode('utf-8')
start = timer()
for i in range(2000):
self.ed.AddText(len(data), data)
self.assertEqual(self.ed.LineCount, i + 2)
end = timer()
duration = end - start
print("%6.3f testAddLineMiddle" % duration)
self.xite.DoEvents()
self.assertTrue(self.ed.Length > 0)
def testHuge(self):
data = (string.ascii_letters + string.digits + "\n").encode('utf-8')
data = data * 100000
start = timer()
self.ed.AddText(len(data), data)
end = timer()
duration = end - start
print("%6.3f testHuge" % duration)
self.xite.DoEvents()
self.assertTrue(self.ed.Length > 0)
def testHugeInserts(self):
data = (string.ascii_letters + string.digits + "\n").encode('utf-8')
data = data * 100000
insert = (string.digits + "\n").encode('utf-8')
self.ed.AddText(len(data), data)
start = timer()
for i in range(2000):
self.ed.InsertText(0, insert)
end = timer()
duration = end - start
print("%6.3f testHugeInserts" % duration)
self.xite.DoEvents()
self.assertTrue(self.ed.Length > 0)
def testHugeReplace(self):
oneLine = (string.ascii_letters + string.digits + "\n").encode('utf-8')
data = oneLine * 100000
insert = (string.digits + "\n").encode('utf-8')
self.ed.AddText(len(data), data)
start = timer()
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)
end = timer()
duration = end - start
print("%6.3f testHugeReplace" % duration)
self.xite.DoEvents()
self.assertTrue(self.ed.Length > 0)
def testUTF8CaseSearches(self):
self.ed.SetCodePage(65001)
oneLine = "Fold Margin=折りたたみ表示用の余白(&F)\n".encode('utf-8')
manyLines = oneLine * 100000
manyLines = manyLines + "φ\n".encode('utf-8')
self.ed.AddText(len(manyLines), manyLines)
searchString = "φ".encode('utf-8')
start = timer()
for i in range(1000):
self.ed.TargetStart = 0
self.ed.TargetEnd = self.ed.Length-1
self.ed.SearchFlags = self.ed.SCFIND_MATCHCASE
pos = self.ed.SearchInTarget(len(searchString), searchString)
self.assertTrue(pos > 0)
end = timer()
duration = end - start
print("%6.3f testUTF8CaseSearches" % duration)
self.xite.DoEvents()
def testUTF8Searches(self):
self.ed.SetCodePage(65001)
oneLine = "Fold Margin=折りたたみ表示用の余白(&F)\n".encode('utf-8')
manyLines = oneLine * 100000
manyLines = manyLines + "φ\n".encode('utf-8')
self.ed.AddText(len(manyLines), manyLines)
searchString = "φ".encode('utf-8')
start = timer()
for i in range(20):
self.ed.TargetStart = 0
self.ed.TargetEnd = self.ed.Length-1
self.ed.SearchFlags = 0
pos = self.ed.SearchInTarget(len(searchString), searchString)
self.assertTrue(pos > 0)
end = timer()
duration = end - start
print("%6.3f testUTF8Searches" % duration)
self.xite.DoEvents()
def testUTF8AsciiSearches(self):
self.ed.SetCodePage(65001)
oneLine = "Fold Margin=NagasakiOsakaHiroshimaHanedaKyoto(&F)\n".encode('utf-8')
manyLines = oneLine * 100000
manyLines = manyLines + "φ\n".encode('utf-8')
self.ed.AddText(len(manyLines), manyLines)
searchString = "φ".encode('utf-8')
start = timer()
for i in range(20):
self.ed.TargetStart = 0
self.ed.TargetEnd = self.ed.Length-1
self.ed.SearchFlags = 0
pos = self.ed.SearchInTarget(len(searchString), searchString)
self.assertTrue(pos > 0)
end = timer()
duration = end - start
print("%6.3f testUTF8AsciiSearches" % duration)
self.xite.DoEvents()
if __name__ == '__main__':
Xite.main("performanceTests")