On Sat, Aug 30, 2014 at 6:00 PM, Edward K. Ream <[email protected]> wrote:

A revised benchmark shows that Qsci.QsciScintilla (Scintilla for
short) is far superior to QTextEdit:

On my relatively slow Windows machine Scintilla loads:

- 500,000 lines in 0.4 sec
- 2 million lines in 1.8 sec.

In each case Scintilla shows *all* the lines immediately, thus
eliminating the chance for data loss.

The benchmark does no syntax coloring.  A later post will consider how
to syntax color using Scintilla, with and without Leo's existing
coloring code.

Edward

P.S. Here is the revised benchmark.  You can run this script from
Leo's body pane provided that stand_alone is False.

import sys
import time
from PyQt4 import QtGui,Qsci

stand_alone = False # True: run outside of Leo
use_qsci = True  # True: use QScintilla
multiplier = 1 # Clicking the button adds 500*1000*multiplier lines.

def add_text(w):
    start = time.time()
    global multiplier
    lines = 500*1000*multiplier
    multiplier += 1
    s = '\n'.join(["This is one line %s of text here"%(i+1)
        for i in range(lines)])
    if use_qsci:
        w.setText(s)
        w.ensureLineVisible(lines-2)
        w.update()
    else:
        w.setPlainText(s) # No guessing.
        w.update()
    print('lines: %8s %s' % (lines,time.time()-start))
    t1 = time.time()
    # s.count takes about as much time as QScintilla.setText!
    # n = s.count('\n')
    # print(r"s.count('\n'):  %s" % (time.time()-start))

if stand_alone:
    app = QtGui.QApplication(sys.argv)
w = QtGui.QWidget()
l = QtGui.QVBoxLayout()
w.setLayout(l)
if use_qsci:
    tw = Qsci.QsciScintilla()
else:
    tw = QtGui.QTextEdit()
b = QtGui.QPushButton('Add text')
l.addWidget(tw)
l.addWidget(b)
w.resize(800,800)
b.clicked.connect(lambda checked: add_text(tw))
w.show()
if stand_alone:
    exit(app.exec_())

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to