/Demos/SpeedDemo/Readme.txt

http://kblib.googlecode.com/ · Plain Text · 52 lines · 43 code · 9 blank · 0 comment · 0 complexity · 5cd39dd95ee3592b0e86ed355165d998 MD5 · raw file

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