AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Desaströse Performance von TRichedit

Ein Thema von Maekkelrajter · begonnen am 11. Sep 2024 · letzter Beitrag vom 12. Sep 2024
Antwort Antwort
Seite 1 von 2  1 2      
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.643 Beiträge
 
Delphi 12 Athens
 
#1

AW: Desaströse Performance von TRichedit

  Alt 12. Sep 2024, 13:24
Festzustehen scheint, dass die aktuelle Implementierung von TRichedit gewissermaßen suboptimal ist.
Ich habe das mal auf einen simplen WinApi-Aufruf reduziert und komme auf ziemlich dieselben Werte. Es hängt also wohl nicht an der Delphi-Implementierung.
Delphi-Quellcode:
  var FN:= 'c:\Users\Uwe\Downloads\TestDateien\Windows_ITunesContent.txt';
// var FN:= 'c:\Users\Uwe\Downloads\TestDateien\MacOS_ItunesContent.txt';
  var S := TFile.ReadAllText(FN, TEncoding.Unicode);
  var sw := TStopwatch.StartNew;
  RichEdit1.SetSelText(S);
  label1.Caption := sw.ElapsedMilliseconds.ToString;
Warum die doppelt so große Windows-Datei aber nur 1/4 der Zeit braucht erschließt sich mir noch nicht so ganz.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.372 Beiträge
 
Delphi 12 Athens
 
#2

AW: Desaströse Performance von TRichedit

  Alt 12. Sep 2024, 13:35
TextDateien ohne Formatierung ... warum überhaupt in ein RichEdit anstatt in ein Memo?
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.643 Beiträge
 
Delphi 12 Athens
 
#3

AW: Desaströse Performance von TRichedit

  Alt 12. Sep 2024, 14:01
TextDateien ohne Formatierung ... warum überhaupt in ein RichEdit anstatt in ein Memo?
Na ja, weil:
Aber einige optische Gimmicks wie mehrfarbiger Text sind eben mit einem TMemo nicht zu realisieren.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.372 Beiträge
 
Delphi 12 Athens
 
#4

AW: Desaströse Performance von TRichedit

  Alt 12. Sep 2024, 15:08
TextDateien ohne Formatierung ... warum überhaupt in ein RichEdit anstatt in ein Memo?
Na ja, weil:
Aber einige optische Gimmicks wie mehrfarbiger Text sind eben mit einem TMemo nicht zu realisieren.
ups.

SynEdit/SynMemo oder dergleichen?
oder das neue Direct2D-RichEdit ... müsste man doch bestimmt gut im FireMokey einbinden können.
(der Start von dem Geraffel dauert zwar ewig, aber danach scheint es schnell zu sein)
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
412 Beiträge
 
#5

AW: Desaströse Performance von TRichedit

  Alt 12. Sep 2024, 15:16
What about this
Delphi-Quellcode:
var
  Stream: TMemoryStream;
begin
  Stream := TMemoryStream.Create;
  try
    Stream.LoadFromFile(FILE_NAME);
    SendMessage(RichEdit1.Handle, WM_SETTEXT, LPARAM(0), WPARAM(Stream.Memory)); // better to add to the stream another byte with 0 or double bytes with 0, but for testing now
    //Stream.Position := 0;
    //RichEdit1.Lines.LoadFromStream(Stream);
  finally
    Stream.Free;
  end;
end;
Kas
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.372 Beiträge
 
Delphi 12 Athens
 
#6

AW: Desaströse Performance von TRichedit

  Alt 12. Sep 2024, 15:23
What about this
And this is supposed to work in a Delphi since 2009?

SendMessage = SendMessageW = Unicode
Is your file also Unicode?
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
412 Beiträge
 
#7

AW: Desaströse Performance von TRichedit

  Alt 12. Sep 2024, 15:29
What about this
And this is supposed to work in a Delphi since 2009?

SendMessage = SendMessageW = Unicode
Is your file also Unicode?
It should !

Notice by sending the stream in full as it in the file, meaning the header included U+FEFF BOM header, yet the Window class recognized it, and handle it right, this even should work with Delphi 5.

But was it faster ?
Kas
  Mit Zitat antworten Zitat
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.643 Beiträge
 
Delphi 12 Athens
 
#8

AW: Desaströse Performance von TRichedit

  Alt 12. Sep 2024, 15:31
Is your file also Unicode?
At least the example files posted above are.

Anyway, the TMemoryStream approach is quite similar to setting the Text or SelText with a string. It doesn't affect the performance, though.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
412 Beiträge
 
#9

AW: Desaströse Performance von TRichedit

  Alt 12. Sep 2024, 16:00
What about this
And this is supposed to work in a Delphi since 2009?

SendMessage = SendMessageW = Unicode
Is your file also Unicode?
Yes after re-reading more, i think WM_SETTEXT with Delphi 5 or may be even Delphi 7 might not work, as it will fail to handle the BOM marker for UTF16, as the used RichEdit class is version 1.0 and it is
Zitat:
ANSI (single-byte character set (SBCS) and multibyte character set (MBCS)) editing
So will work if the class changed to version 2.0, yet i might be wrong though, all in all this need more digging.
Kas
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
412 Beiträge
 
#10

AW: Desaströse Performance von TRichedit

  Alt 12. Sep 2024, 14:52
Well, if someone reading my writing somewhere, then try this

Delphi-Quellcode:
var
  Stream:TMemoryStream;
begin
  Stream := TMemoryStream.Create;
  try
    Stream.LoadFromFile(FILE_NAMEXX);
    Stream.Position := 0;
    RichEdit1.Lines.LoadFromStream(Stream);
  finally
    Stream.Free;
  end;
end;
The problem is known, which is the ****** stream handling in RTL, and also in VCL, it does many small read at 2kb (like it was bronze age) instead of 64kb, anyway TMemoryStream will load this stuff in full in memory and feed it, this should be faster, (Well in theory and in my slow brain)
Kas
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:13 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz