PageRenderTime 35ms CodeModel.GetById 30ms app.highlight 1ms RepoModel.GetById 3ms app.codeStats 0ms

Plain Text | 52 lines | 43 code | 9 blank | 0 comment | 0 complexity | 5cd39dd95ee3592b0e86ed355165d998 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0
 1Speed demo - shows how fast can be load/save million(s) of dynamic records
 3Record/db-like structure is declared at top of uMainForm.pas unit.
 5Disk access time is not measured, because all operations are made in memory.
 6When saving, whole record structure is saved to TMemoryStream with
 7single allocation, because TKBDynamic.WriteTo has APreAllocSize=True,
 8so no reallocations are made at all. After saving structure to memory,
 9whole content are save directly to TFileStream.
10Similar with Load, first whole file is loaded to TMemoryStream, and then
11loaded to dynamic record.
12Of course you can save/load directly from TFileStream, but it could be
14Best would be use for example some file memory mapping streams, then you could
15probably get better performance when taking disk-io access.
17Log from my laptop saving/loading 10M (by default it's 1M in spin edit) of records:
19	--- Save
20	Record count: 10000000
21	Allocating DB took 0,0236s
22	Fill DB took 2,2998s
23	Saving DB to TMemoryStream took 0,8902s
24	DB size 360,28MB
25	--- Load
26	Loading DB from TMemoryStream took 0,8107s
27	Record count: 10000000
29When UTF8 checkbox is checked, then log looks like this:
31	--- Save
32	Record count: 10000000
33	Allocating DB took 0,0242s
34	Fill DB took 2,3502s
35	Saving DB to TMemoryStream took 2,1312s
36	DB size 218,29MB
37	--- Load
38	Loading DB from TMemoryStream took 1,5473s
39	Record count: 10000000
41In UTF8 mode, saving is 2.5x longer, because of conversion UnicodeString->UTF8String,
42but DB size dropped about 30%.
43Keep in mind that it's only 2,5s to store 10M dynamic-records in this case!
45Please also note that this demo is not to show how build/replace your DB.		
46There is not indexing, searching, etc. You can only save/load any (big)
47dynamic record structure, and have direct native access to it.
48But it's possible to build 'real' DB-like on top of TKBDynamic.
50License:   MPL 1.1/GPL 2.0/LGPL 3.0