Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 11/25/20 in all areas

  1. I just had to do it... Go with the flow! It's the Black Friday / Cyber Monday "season", so I had to rush the book offer The book was actually scheduled for release in early December, but then the Black Friday deals started popping up all over the place... pressure was building... and I finally caved in! I cut the darn thing in two, and decided to offer Part I at a discount, and will give Part II for free to all Buyers. Not really a 97% BF discount but hey... Junior is still studying, and we still have to pay the bills (Corona doesn't help, either)! So, here it is! I hope you'll like it like you did Delphi Memory Management! https://dalija.prasnikar.info/delphiebap/index.html Thank you all for the support!
  2. Alexander Sviridenkov

    HTML Library review and sale: 25% off.

    New review from Jon Aasenden: https://jonlennartaasenden.wordpress.com/2020/11/25/htmlcomponents-for-delphi-a-closer-look/ HTML Library and Office Library sale: 25% discount on all delphihtmlcomponents.com products until end of the month. Please use coupon code BF2020
  3. As a guideline: try to remove overhead from prologues and epilogues caused by variables of managed types (explicit or implicit) such as strings or interfaces that are only there for the uncommon path. Another example was the error raising code in the hextobin thread that can be put into a subroutine that gets called only when the rase case of a invalid char occurs. Eric Grange wrote a nice article about this some years ago that I like to recommend: https://www.delphitools.info/2009/05/06/code-optimization-go-for-the-jugular/
  4. No I don't think so. You've just made your code more complex and harder to maintain and gained almost nothing.
  5. Wrong. It's faster because you don't have a managed type as a local variable. a procedural type would be enough, no pointer needed
  6. A new patch for Delphi 10.4.1 is available, addressing iOS 14 and macOS Big Sur issues. Download via GetIt or the new customers porta. For more information see https://blogs.embarcadero.com/apple-platforms-patch-for-rad-studio-10-4-1/
  7. As a special treat to those who would like to move up to the best Delphi database engine for embedded use, we have a great offer for you! From now until November 30th, take a whopping 66% off the full price of our NexusDB Embedded Source version; approx price after rebate is US$150. To purchase, go to our webshop: https://www.nexusdb.com/support/index.php?q=pricing Please enter the coupon code BLACKFRIDAYEMB during checkout to apply the rebate. Note: only valid for new licenses, and only for the Embedded Source SKU. Regards, The NexusDB Team
  8. Or as a friend advised me when I started learning to code, on my wood-burning CPU: First make it work, then worry about performance.
  9. Not sure if this is of any value in your case, but I remember analyzing Process Monitor log and discovering my exe unnecessary accessing/or repeated opening, closing Registry (instead of open once and access and close when not used anymore). I also discovered it was trying accessing some non-existent files on the disk, causing slow load/start time. This was not very clear at analyzing source. https://docs.microsoft.com/en-us/sysinternals/downloads/procmon
  10. "Premature optimization" is a phrase used to describe a situation where a programmer lets performance considerations affect the design of a piece of code. This can result in a design that is not as clean as it could have been or code that is incorrect, because the code is complicated by the optimization and the programmer is distracted by optimizing. "Premature optimization is the root of all evil." December 1974 Test-driven development is related to the test-first programming concepts of extreme programming, begun in 1999, but more recently has created more general interest in its own right. Just move on.
  11. There is another one out there, which hasn't turned up yet. Something to the effect that 90% of programmers are wrong 90% of the time about where to optimize.
  12. dummzeuch

    GExperts menu too long

    The credit for this goes to my predecessors. It was already there when I took over GExperts (but I had to fix it several times because of bloody IDE theming). It probably was necessary in the 1990s, when screen space was at even more a premium than today.
  13. My memory is already bad, just ask my wife 🙂
  14. That's a very short sighted attitude. Technical debt accumulates and your memory will not get better with age, or so I've heard
  15. Are you guys suggesting that I set the function type at the time when I set the flag (SetFlag), something like: flag := SetFlag; // flag is initialize on Project start if flag then ProcessString := ProcessStringWhenFlagIsTrue else ProcessString := ProcessStringWhenFlagIsFalse; // function type type TProcessStringType = function(const aStr: string): string; ProcessString = TProcessStringType; // usage of ProcessString function vStr := ProcessString('x'); ?
  16. You could remove the flag, by the use of a PointerVariable as pointer to function. In SetFlag, you can switch the PointerVariable to the desired, real function, so that the PointerVariable always willl be valid. Then just calling the PointerVariable will not need any conditional check inside.
  17. Steve Maughan

    NERO5 chess engine

    Deep Blue was IBM’s pet project from the late 90’s and has never been available for public scrutiny. It’s estimated strength is about 2800 ELO. To put this in context, if the latest Stockfish, running on a iPhone, played 100 games against Deep Blue it would win at least 95.
  18. Rollo62

    TBluetoothLE in Windows 10

    Have you checked out the functionality with some tools, like https://www.microsoft.com/de-de/p/bluetooth-le-lab/9n6jd37gwzc8?activetab=pivot:overviewtab https://www.microsoft.com/de-de/p/bluetooth-le-explorer/9n0ztkf1qd98?activetab=pivot:overviewtab https://www.nirsoft.net/utils/bluetooth_viewer.html https://www.nirsoft.net/utils/bluetoothcl.html https://sensboston.github.io/BLEConsole/ Of course the Nordic tools should be great too, but thats already developer tools for the MCU's, but they have a lot of helpful tools as well. https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Connect-for-desktop Maybe someone knows better tools for Windows, since I usually work with Android/iOS.
  19. David Heffernan

    Hex2Binary

    You can extend my benchmark program in earlier posts to see how it performs.
  20. David Heffernan

    Hex2Binary

    This code is very easy to verify that it is safe. For more complex code, that may not be the case, and so pointers could be risky. I was using pointers here for performance reasons. Copy a bunch of characters in one go rather than character by character. Others showed much better ways to do it than my initial attempt.
  21. Steve Maughan

    NERO5 chess engine

    I'm reasonably well know in the field of computer chess and competed in the 2015 World Computer Chess Championships. Although Delphi is my first language, my engine was written in plain old "C". However, there are a number of strong open source chess programs written in Delphi. Here are a few: Booot: booot6_4_release.rar (dropbox.com) Open-Critter: GitHub - rchastain/open-critter: UCI chess engine written in Pascal by Richard Vida Durandal: GitHub - rchastain/durandal: UCI chess engine written in Pascal Steve
  22. Mahdi Safsafi

    Hex2Binary

    @Stefan Glienke @Kas Ob. Got some time and tried to do full simd ... The result is awesoooome !!! Can we go further ? yep (using ymm but this is not gonna be easy as Delphi doesn't support it yet) type TChar4 = array [0 .. 3] of Char; PChar4 = ^TChar4; const { Source Data Format : Imm8[1:0] } DF_UNSIGNED_BYTES = 0; DF_UNSIGNED_WORDS = 1; DF_SIGNED_BYTES = 2; DF_SIGNED_WORDS = 3; { Aggregation Operation : Imm8[3:2] } AGGREGATION_OP_EQUAL_ANY = 0 shl 2; AGGREGATION_OP_RANGES = 1 shl 2; AGGREGATION_OP_EQUAL_EACH = 2 shl 2; AGGREGATION_OP_EQUAL_ORDERED = 3 shl 2; { Polarity : Imm8[5:4] } POLARITY_POSITIVE = 0 shl 4; POLARITY_NEGATIVE = 1 shl 4; POLARITY_MASKED_POSITIVE = 2 shl 4; POLARITY_MASKED_NEGATIVE = 3 shl 4; { Output Selection : Imm8[6] } OS_LSI = 0 shl 6; OS_MSI = 1 shl 6; OS_BIT_MASK = 0 shl 6; OS_BYTE_WORD_MASK = 1 shl 6; const [Align(16)] AndMaskData: array [0 .. 7] of SmallInt = (31, 31, 31, 31, 31, 31, 31, 31); RangeData: array [0 .. 7] of WideChar = '09afAF' + #0000; TableData: array [0 .. 25] of TChar4 = ('????', '1010', '1011', '1100', '1101', '1110', '1111', '????', '????', '????', '????', '????', '????', '????', '????', '????', '0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001'); function _HexToBinGhost(P, Q: PChar; Len: Integer): Boolean; asm push ebx push esi push edi mov ebx, ecx jz @@Empty lea esi, [TableData ] mov edi, ecx and ebx, 7 // trailing shr edi, 3 // number of simd-run jz @@HandleTrailing // too small to be done using simd movdqa xmm0, [AndMaskData] movdqa xmm1, [RangeData ] @@SimdLoop: movdqu xmm3, [eax] { check if its a valid hex } pcmpistri xmm1, xmm3, DF_UNSIGNED_WORDS or AGGREGATION_OP_RANGES or POLARITY_NEGATIVE or OS_LSI ja @@Process { either end (null terminated) or invalid char } test Word [eax + ecx *2], -1 // is NT ? => continue jnz @@InvalidChar @@Process: pand xmm3, xmm0 // and each element with 31 pxor xmm2, xmm2 { --- first four chars --- } movdqa xmm4, xmm3 { first two char } punpcklbw xmm4, xmm2 // unpack low data pcmpeqq xmm2, xmm2 // generate mask // gather two TChar4 = 2*SizeOf(TChar4) = 16 bytes db $c4, $e2, $e9, $90, $2c, $e6 // vpgatherdq xmm5,QWORD PTR [esi+xmm4*8],xmm2 movdqu [edx], xmm5 // store to result { second two char } pshufd xmm4, xmm4, $0E // move next two elements to low pcmpeqq xmm2, xmm2 // gather two TChar4 db $c4, $e2, $e9, $90, $2c, $e6 // vpgatherdq xmm5,QWORD PTR [esi+xmm4*8],xmm2 movdqu [edx+16], xmm5 { --- last four chars --- } { first two char } pxor xmm2, xmm2 punpckhbw xmm3, xmm2 // unpack high data pcmpeqq xmm2, xmm2 db $c4, $e2, $e9, $90, $2c, $de // vpgatherdq xmm5,QWORD PTR [esi+xmm3*8],xmm2 movdqu [edx+32], xmm5 { second two char } pshufd xmm3, xmm3, $0E pcmpeqq xmm2, xmm2 db $c4, $e2, $e9, $90, $2c, $de // vpgatherdq xmm5,QWORD PTR [esi+xmm3*8],xmm2 movdqu [edx+48], xmm5 add eax, 16 add edx, 16 * 4 dec edi jnz @@SimdLoop test ebx, ebx jz @@NoTrailing @@HandleTrailing: mov ecx, ebx @@LegacyLoop: movzx edi, word [eax] lea ebx, [edi - 48] cmp ebx, 9 jbe @@Copy lea ebx, [edi - 65] cmp ebx, 5 jbe @@Copy lea ebx, [edi - 97] cmp ebx, 8 ja @@InvalidChar @@Copy: and edi, 31 movq xmm0, [esi + edi * 8] movq [edx], xmm0 add eax, 2 add edx, 8 dec ecx jnz @@LegacyLoop @@NoTrailing: mov word[edx], 0 // NT. @@Empty: mov eax, True @@End: pop edi pop esi pop ebx ret @@InvalidChar: xor eax, eax jmp @@End end; function HexToBinGhost(const Value: string): string; begin SetLength(Result, Length(Value) * 4); if _HexToBinGhost(Pointer(Value), Pointer(Result), Length(Value)) then exit; raise EConvertError.CreateFmt('Invalid hex digit found in ''%s''', [Value]); end;
  23. Mahdi Safsafi

    Hex2Binary

    Agree ! One thing I noticed, people complain too much about compilation time(which could be a principal factor that influences EMB decision about optimization) ! I clearly understood that as a fast compilation time makes us all happy. But this shouldn't come at a cost of emitting a poor code. If someone likes a fastest compiler ... Know for sure that clients also like fastest app! A well generated code as general means things gets done quickly, for server it means less power consumption (saving bill). On mobile, friendly for battery life (happy client), ... etc.
×