Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 02/20/22 in all areas

  1. I was trying to improve the performance of SynEdit in handling files with super long lines (e.g. 50K characters). In doing so I came across an unexpected optimization that had a spectacular impact on performance. See this innocent looking function probably written two decades ago (fCasedLine is a PChar): function TSynCustomHighlighter.GetToken: string; var Len: Integer; begin Len := Run - fTokenPos; SetLength(Result, Len); if Len > 0 then StrLCopy(@Result[1], fCasedLine + fTokenPos, Len); end; By measuring I found that this function (called zillions of times) was a bottleneck and replaced it with: function TSynCustomHighlighter.GetToken: string; var Len: Integer; begin Len := Run - fTokenPos; SetString(Result, fCasedLine + fTokenPos, Len); end; The impact was massive. Both SetString and StrLCopy in x64 are implemented in pascal (not assembly) using Move. So initially I was puzzled. However here is the reason. Look at StrLCopy: function StrLCopy(Dest: PWideChar; const Source: PWideChar; MaxLen: Cardinal): PWideChar; var Len: Cardinal; begin Result := Dest; Len := StrLen(Source); if Len > MaxLen then Len := MaxLen; Move(Source^, Dest^, Len * SizeOf(WideChar)); Dest[Len] := #0; end; Can you see the problem? It is the call to StrLen(Source)! In my case the Source was very very long strings, the length of which was unnecessarily calculated the hard way. The lesson here is that you need to identify the bottlenecks by measuring. You may be in for surprises, sometimes pleasant ones,
  2. If you want, I can put a PDF attachment and * .docx. Perhaps the author is not angry.
  3. corneliusdavid

    Syntax error in From clause

    Firebird is awesome--works well as either embedded or server, so it can scale with your app. SQLite is small and nimble and available on every single platform. If you have a choice, do not use Access--you will have many problems down the road.
  4. David Heffernan

    Enhanced messageboxes

    No. You just read the Win32 docs and off you go.
  5. dummzeuch

    A book about Object Pascal Style Guide

    I hadn't noticed. In that case it's OK to post it.
  6. pyscripter

    String optimization

    TStopwatch and occasionally VTune.
  7. Stano

    Syntax error in From clause

    It depends on the purpose of use. If it is an embedded / local version, I recommend Firebird. There is no need to install anything. Just copy. Access is, as usual with MS, unlike other DBs. You will not acquire the right habits.
  8. Hi, I started create a simple media player based on the Windows Media Foundation. I have to deal with DRM encrypted channels so there is unluckily no way around. Did somebody have some experience with the Windows Media Foundation and DRM? The attached demo is a player using WMF and Firemonkey. The header files used in this project can be found here: https://github.com/FactoryXCode/MfPack You should be able to play streams (based on dash and HLS) as well as media files located on the local file system. It partially crashes here on my vm inside the the d3d11.dll. I did not tested it on a native windows system yet. The player also uses some "technique" to render firemonkey elements on top of the video. To do so you just have to put them as child object to the player. Christian fmxwmf.zip
  9. shineworld

    Place image in a TImage

    Initially failed to understand how in Demo29 the use of PIL allowed to place an image in a TImage object. But slowly I succeeded: rgb_im = PIL_Image.fromarray(np.uint8(frame)).convert('RGB') self.imgFrameI.Picture.Bitmap.SetSize(rgb_im.width, rgb_im.height) dib = PIL_ImageWin.Dib(rgb_im) dib.expose(self.imgFrameI.Picture.Bitmap.Canvas.Handle) self.imgFrameI.Repaint() rgb_im = PIL_Image.fromarray(np.uint8(frame_out)).convert('RGB') self.imgFrameO.Picture.Bitmap.SetSize(rgb_im.width, rgb_im.height) dib = PIL_ImageWin.Dib(rgb_im) dib.expose(self.imgFrameO.Picture.Bitmap.Canvas.Handle) self.imgFrameO.Repaint() Now perfectly works and from 30FPS of PySimpleGUI version, I've reached 89 stable FPS with delphivcl version. AMAZING how fast delphi vcl is"
  10. The 14th of February is just around the corner, and while for many that means chocolates and flowers, we know the true meaning: Delphi’s birthday! Feb 14, 2022 10:00 AM CST [Register] The theme of Delphi’s 27th anniversary is Building the Future! It is always great to tell the story of how you discovered Delphi, but let’s look to the future. How do you see Delphi making the world a better place? What Delphi related technologies continue to change the way you program? We are hosting a webinar with Kyle Wheeler, Marco Cantu, David Millington, and Ian Barker, where we share the ways Delphi continues to shape the future of software development.
×