Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

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

Re: himXML (gesprochen himixML)

  Alt 25. Mai 2009, 13:33
OK, dann setz ich mich mal daran


Für Leute wie Luckie, ist die Classes-Unit "deaktivierbar" (siehe Compilerschalter UseClassesUnit in himXML.pas).

Allerdings gehen dann einige Funktionen flöten, da ich dann nicht jeden popligen Stream redefinieren will.
Delphi-Quellcode:
TXMLFile = Class
Public
  {$IFDEF UseClassesUnit}
  Procedure LoadFromResource(Instance: THandle; Const ResName: String; ResType: ...
  Procedure LoadFromResource(Instance: THandle; ResID: Integer; ResType: ...
  Procedure LoadFromXML (Const XMLString: AnsiString);
  Procedure LoadFromXML (Const XMLString: TWideString);
  Procedure SaveToXML (Var XMLString: AnsiString);
  Procedure SaveToXML (Var XMLString: TWideString);
  Property asXML: AnsiString;
  {$ENDIF}
End;

TXMLNode = Class
Public
  {$IFDEF UseClassesUnit}
  Property XMLData: TWideString;
  {$ENDIF}
End;
In der himXML_Tools.pas wurde an entsprechender Stelle (TXMLIniFile.ReadBinaryStream und Co.) eine Umleitung eingebaut, da dort Aufgrund der Nutzung von TStringList Classes nicht deaktiviert werden kann (falls man diese Zusatzunit nutzt und in himXML.pas es dennoch abgeschaltet hat)


Die Demo_Tree.dpr würde überarbeitet:
es gibt jetzt eine Ladefortschrittsanzeige und das Füllen der Treeview kann via [X] abgebrochen werden


Die Parsingfunktion wude überarbeitet, an vielen Stellen gab es ja 2 Funktionsaufrufe pro gelesendem Zeichen
While _CheckLen(i, i, P) and CheckChar(P[i], xcSpace) do Inc(i); stattdessen gibt es jetzt nur noch eine Funktions, in welcher durchschnittlich nur noch eine optimiertere Inline-Funktion pro Zeichen vorkommt.
_Search(P, i, 0{isSpace...}); (wenn ich da alles geprüft hab, dann kommen die alten, auskommentieren Schleifen auf der TXMLFile.ParsingTree raus)



Hab noch 'nen krasses SpeedUp hinbekommen (teilweise um über 90% runter) und das vorwiegend nur dadurch, daß ich Delphi teilweise die "sinnlose" Speicherverwaltung abnahm.

Speziell Length(S) und S[x] für Wide-/UnicodeStrings hab ich durch eigene Inline-Funktionen ersetzt.
Was hatt denn bitte sehr ein UniqueString in Length zu suchen? (und das was noch nichtmal alles)


Dann bin ich sehr überrascht:
Erstmal ist D2009 manchmal sogar einen Hausch schneller, als TDE und die Dateigrößer
Und normaler Weise wird doch mit jeder neuen Delphi-Version die EXE etwas größer, aber ...
(die CheckLibs.dpr mit allen Tests für meine Lib und die anderen Libs deaktivert)
> TDE > 471 KB
> D09 > 224 KB
Und auch wenn beim UnicodeString mehr intern passiert, wirkt sich insgesammt die Refferenzzählung etwas positiver aus.
Nur das mit den Dateigrößen ist mir im Moment noch etwas schleierhaft.
OK, dafür verbraucht TDE teilweise bis 10% weniger RAM.


Da Aufgrund der neuen Node-Verwaltung TXMLNode um 8 Byte größer wurde, passen jetzt nicht mehr über 4.000.000 der Testnodes (incl. 2 Attributen und etwas Text) in 2 GB RAM, sondern nur noch 2.500.000 bis 2.800.000 (je nach Speicherfragmentierung und -auslastung)



aktuelle Tests/Vergleiche:
Code:
> Delphi 2009 (CheckLibs_D2009.exe)
> Turbo Delphi Explorer (CheckLibs_TDE.exe)
> alle Tests komplett (CheckLibs.exe bzw CheckLibs.dpr)

********************************************************************************
***** Delphi 2009 **************************************************************
********************************************************************************

fill TXMLFile with 10.000 nodes and save this into a file
create:0  fill:10  save:6  free:3


fill TXMLFile with 10.000 nodes, delete 8.000 nodes and save this into a file
create:0  fill:10  delete:355  save:3  free:0


fill TXMLFile with 10.000 nodes with attributes and save this into a file
create:0  fill:26  save:14  free:4


fill TXMLFile with 100.000 nodes, save into and load this from a file
create:0  fill:225  save:134  free:50
create:0  load:349  free:47


fill TXMLFile with 10.000 nodes with attributes and search nodes
create:0  fill:26  search:2519  free:4


fill TXMLFile with 3.500.000 nodes, save into and load this from a file
create:0  fill:16895  save:11906  free:2489
create:0  load:24578  free:2376


load a file into TXMLFile with 3.500.000 nodes as SAX mode
create:0  load:32381  free:0

********************************************************************************
***** Turbo Delphi Explorer ****************************************************
********************************************************************************

fill TXMLFile with 10.000 nodes and save this into a file
create:0  fill:13  save:6  free:3


fill TXMLFile with 10.000 nodes, delete 8.000 nodes and save this into a file
create:0  fill:14  delete:391  save:3  free:0


fill TXMLFile with 10.000 nodes with attributes and save this into a file
create:0  fill:42  save:18  free:7


fill TXMLFile with 100.000 nodes, save into and load this from a file
create:0  fill:332  save:176  free:87
create:0  load:463  free:97


fill TXMLFile with 10.000 nodes with attributes and search nodes
create:0  fill:45  search:2669  free:8


fill TXMLFile with 3.500.000 nodes, save into and load this from a file
create:0  fill:24055  save:15371  free:5979
create:0  load:31400  free:6208


load a file into TXMLFile with 3.500.000 nodes as SAX mode
create:0  load:48734  free:0

********************************************************************************
***** komplett (D2009) *********************************************************
********************************************************************************


SetProcessAffinityMask: OK

use QueryPerformanceCounter

precreating used strings - do not create and convert this within the measuring
create:39


fill TXMLFile with 10.000 nodes and save this into a file
create:0  fill:9  save:6  free:2

fill MS-XML-DOM with 10.000 nodes and save this into a file
create:3  fill:6827  save:157  free:0

fill ThaXML with 10.000 nodes and save this into a file
create:0  fill:4  save:11  free:33


fill TXMLFile with 10.000 nodes, delete 8.000 nodes and save this into a file
create:0  fill:9  delete:392  save:3  free:0

fill MS-XML-DOM with 10.000 nodes, delete 8.000 nodes and save this into a file
create:0  fill:6778  delete:88233  save:88  free:0

fill ThaXML with 10.000 nodes, delete 8.000 nodes and save this into a file
create:0  fill:4  delete:35  save:0  free:0


fill TXMLFile with 10.000 nodes with attributes and save this into a file
create:0  fill:26  save:36  free:5

fill MS-XML-DOM with 10.000 nodes with attributes and save this into a file
create:0  fill:6819  save:113  free:0

fill ThaXML with 10.000 nodes with attributes and save this into a file
create:0  fill:5  save:11  free:33


fill TXMLFile with 100.000 nodes, save into and load this from a file
create:0  fill:211  save:134  free:48
create:0  load:324  free:43

fill MS-XML-DOM with 100.000 nodes, save into and load this from a file
create:0  fill:750833  save:247  free:0
create:0  load:317  free:93

fill ThaXML with 100.000 nodes, save into and load this from a file
create:0  fill:46  save:117  free:2922
create:0  load:401087  free:2920


fill TXMLFile with 10.000 nodes with attributes and search nodes
create:0  fill:25  search:2577  free:4

fill MS-XML-DOM with 10.000 nodes with attributes and search nodes
create:0  fill:6985  search:140237  free:0

fill ThaXML with 10.000 nodes with attributes and search nodes
create:0  fill:5  search:10136  free:33


fill TXMLFile with 3.500.000 nodes, save into and load this from a file
create:0  fill:15785  save:11503  free:2400
create:0  load:24203  free:2268

fill MS-XML-DOM with 3.500.000 nodes, save into and load this from a file
error: das ist wirklich keinem zumutbar

fill ThaXML with 3.500.000 nodes, save into and load this from a file
error: EOutOfMemory würde sich so ab 2.000.000 melden
error: ab etwa 500.000 braucht .Free ewig und es steigt expotentiel an
       es sind hiermit also efektiv nicht viel mehr als 200.000 möglich
fill ThaXML with 200.000 nodes, save into and load this from a file
create:0  fill:242  save:1054  free:11694
error: das Laden würde ewig brauchen
fill ThaXML with 15.000 nodes, save into and load this from a file
create:0  fill:17  save:62  free:54
create:0  load:47741  free:54


load a file into TXMLFile with 3.500.000 nodes as SAX mode
create:0  load:31928  free:0

load a file into MS-XML-DOM/SAX with 3.500.000 nodes as SAX mode
error: ich weiß noch nicht wie das geht

load a file into ThaXML with 3.500.000 nodes as SAX mode
error: this class do not support this

press [enter]


Download siehe Post #1
( ~1 MB incl. 2 XML-Testdateien und den wichtigsten Binaries )
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat