Delphi Redis Client available through GetIt Package Manager

Delphi Redis Client
Delphi Redis Client Logo

Since some days ago, Delphi Redis Client, the official redis client for Delphi, is available through GetIt.

You can get the library with just a click, now there aren’t reasons to be afraid by Redis utilization 🙂

More info and the (very simple) installation instruction at the dedicated page.

The official repository if on github https://github.com/danieleteti/delphiredisclient

Echoes From The Past: Message Master For Delphi a.k.a. MM4D

Some years ago, at the Delphi 6/7 timeframe I was working on a client/server program with c.a. 400 forms and 200 units. At that time I needed a simple way to localize in Italian (in primis) and in other languages, all the  standard dialogs (ShowMessage, InputBox, InputQuery etc.). Moreover, I would have liked to give a unique style to them. In addition, I needed to localize that dialogs. Moreover I needed a simple way to show a program of a background operation using a not modal dialog with a simple pattern like the following:

  ...
  ShowStatusPos(STATUS_CAPTION, Point(50, 50), True);
  try
    for i := 1 to 100 do
    begin
      SetupQuery(LMyDataset, i);
      LMyDataset.Open;
      while not LMyDataset.Eof do
      begin
        //do something
        UpdateStatus(i, Format(STATUS_CAPTION + ' %2d%%', [i]));
        LMyDataset.Next;
      end;
      LMyDataset.Close;
    end;
  finally
    CloseStatus;
  end;
  ...

So, after some tests I wrote Message Master for Delphi. MM4D is a smal library which supports all of these features, or at least these features were supported at that time. Indeed, since then I saw many (really many) 3rd-party Delphi/C++Builder written programs which actually use MM4D. However, since then I didn’t supported that library anymore. Now, more or less, 15 years after, a user wrote to my about MM4D support in Delphi 10 Seattle. So, I decided to update the code to let it compile on Delphi 10 Seattle. So, now it is currently supported (even if I dont plan to improve it in any way in the short term). However if someone use it or want to use it and update/upgrade/improve, here’s the github reporitories. I hope I have done something good for all the old time users.

Message Master For Delphi
https://github.com/danieleteti/mm4delphi

In the repositories there is a demo to show all the features of MM4D and there is also a small tool called UnitsAdded.exe which can be used to add the MM4D features to a project automatically (search for Dialogs.pas and, if exists, add MessDlgs after it).
MM4Delphi uses the good XiControls (included). So, still thank you to Eugene Genev for his XiControls.

Migration to github for all my open source projects… done!

Since when Google announced that Google Code will be closed I did start to plan the migration of all my open source projects. Now, the migration is terminated.

In the next days, I’ll add all the contributors too, so that the development can go forward as usual.

These are the projects

  • DelphiMVCFramework
    • if you are reading my Delphi Cookbook, please use this new repository instead of the old SVN one, reported in the book.
  • DORM, the Delphi ORM
  • DelphiRedisClient
  • DelphiDIContainer
  • DelphiSTOMPClient

All the repositories are available on my personal github page https://github.com/danieleteti and, as usual all contributions are welcome.

Enjoy.

 

#1 “dorm, the Delphi ORM” bullettin

This is the first post regarding a fast update on the last changes to the dorm project in terms of management and code.

  • Welcome to 2 new contributors: mrbar2000 and magnomp (this is the full list http://code.google.com/p/delphi-orm/people/list)
  • Added a PersistentStrategy for SQLite.
  • New Google Group related to dorm. Post your questions, comments and request here!
  • Added support for Generics Collections. No more needs of TdormCollection. You classes are completely decoupled from the framework.
  • A brand new mapping strategy is under development. There will be “3 levels” of mapping: Config File, RTTI Attributes and “Conventions Over Configuration” (CoC) (do you wanna check the code in dev branch? Click here)
  • Added more unittests
  • Roadmap updated
  • Initial support for MS SQLServer in a development branch (Thanks to Claudio Regonat)
There are plenty of new features still to come. Stay tuned!

DataSnap Filters Compendium

What’s DataSnap Filters Compendium

DataSnap Filters Compendium (DSFC) is a compendium of 9 filters for DataSnap 2010.
The filters are divided into 3 groups:

HASH
MD5
MD4
SHA1
SHA512

CIPHER
Blowfish
Rijndael
3TDES
3DES

COMPRESS
LZO

HASH filters
The HASH filters helps avoid to any spiteful person to modify datasnap message through an “Man in the middle” attack (http://en.wikipedia.org/wiki/Man-in-the-middle_attack).
Functioning is basing on an easy principle. After sending the message, the filter calculates the hash of the message and tags along it to the message. When the message gets to destination, the filter recovers the hash calculated by the client and recalculates it on the remaining part of the message.
If the part of the extrated hash (calculated at the beginning) and the hash recalculated to the end are equal, the message hasn’t change.
To avoid someone could modify the message and also recalculates the hash, after calculating the hash, a GUID is tagged along to the message, which just the sender and the receiver know.
This kind of filters DOES NOT AVOID THE UNAVOIDED READING OF DATA,it avoids just the modification.

CIPHER filters
The CIPHER filters are the most interesting filters. Many datasnap users have requested a built-in system to get the data transmission safe. This set of filters colud be the answer.
In the actual version I’ve implemented Symmetric-key algorithms. Maybe I’m going to develop of Asymmetric-key algorithms filters.
Implemented algorithms features are well known, I list them as follows just to be completed:

Blowfish
Blowfish has a 64-bit block size and a variable key length from 32 up to 448 bits.
The filter version has a keysize = 56 byte.

Rijndael
AES Round 2.
AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, whereas Rijndael can be specified with block and key sizes in any multiple of 32 bits, with a minimum of 128 bits and a maximum of 256 bits.
The filter version has a keysize = 32 byte.

3TDES
Triple DES with 24 byte Blocksize, 24 byte Keysize 168 bits relevant
The filter version has a keysize = 24 byte.

3DES
Triple DES with 8 byte Blocksize, 24 byte Keysize 168 bits relevant
The filter version has a keysize = 24 byte.

COMPRESS filters
Actually the LZO compression is the only one that exists, and is one of the faster compression algorithms.
The compression ratio compared to the ZLib is worse but about 3 times faster (as the table in next paragraph shows).

Tests
DSFC has a huge suite of unit tests and speed tests.
The speed tests show how filters are fast and how the data stream size is affected by their work. Follow table contains results of speed test execution (DSFCSpeedTest) on my workstation. If you want give a meaning to those numbers, see the code of the speed test 🙂

== HASH FILTERS == 1000 iterations
MD5             =  161ms (stream size:  8304 byte, filtered stream size:  4184 byte)
MD4             =   99ms (stream size:  8304 byte, filtered stream size:  4184 byte)
SHA1            =  145ms (stream size:  8304 byte, filtered stream size:  4192 byte)
SHA512          =  344ms (stream size:  8304 byte, filtered stream size:  4280 byte)

== CIPHER FILTERS == 1000 iterations
Blowfish        =  898ms (stream size:  8304 byte, filtered stream size:  8304 byte)
Rijndael        =  941ms (stream size:  8304 byte, filtered stream size:  8304 byte)
3TDES           = 1729ms (stream size:  8304 byte, filtered stream size:  8304 byte)
3DES            = 1757ms (stream size:  8304 byte, filtered stream size:  8304 byte)

== COMPRESS FILTERS == 1000 iterations
LZO             =   79ms (stream size:  8304 byte, filtered stream size:  1113 byte)
ZLibCompression =  295ms (stream size:  8304 byte, filtered stream size:   799 byte)

Last speed test is for the only filter included in Delphi2010. It’s included only for compare times and data stream size with the other filters.

After you install DataSnapFiltersCompendium.bpl you will see following filters into the “Filters” property

New filters registered by DSFC
New filters registered by DSFC

Cipher filters have only one property for the encription key

Encryption key for the cipher filters
Encryption key for the cipher filters

Project Source Contains

  • Full Filters Code
  • Unit Test
  • SpeedTest

Download DataSnap Filters Compendium

P.S. I’ll be at ITDevCon… and you? 🙂

Delphi profiling made simple… really simple!

Many users asked Embarcadero to include a profiler in the next Delphi for Win32.

Waiting for this, there are some interesting tools for profile a Delphi program.

For example, AsmProfile is an Open Source sampling profiler wich is very simple to use.

UPDATE:

Actually AsmProfile is an “Instrumenting” profiler. It uses runtime function detouring and assembly to profile any selected function.

If you dont know differences between Instrumenting profiler and Sampling profiler, you can go here or here and read about it.

So, Suppose to have a slow code like this:

Download AsmProfiler from SVN or project home page (see the end of the article).

Now you can put 2 unit in your uses clause and initialize profiler interface directly in your dpr

So far so good… compile your app with following settings:
Delphi -> Project Options:

  • Linker -> Map file = detailed
  • Compiler -> Optimization = off
  • Compiler -> Stack frames = on

In this way, the profiler can reach procedures address for profiling phase.
Run your application and a small form will show up. In this form your must select the profiled methods and then click “Start”.

Now stress your application, click “Stop” and then “Show Results”.
In the “results” form will be shown detailed information about program execution.

Every call timing is splitted in “Calls”, “Parent Calls” and “Child calls” and some stats has been calculated too.

AsmProfiler It’s not complete like AQTime from AutomatedQA, but it’s a very usefull tool for every Delphi programmer.

You can find AsmProfiler here but I suggest to download the updated SVN version.

UPDATE:

AsmProfile can also profile your code without change source using DllInjection.

When you only have an executable:

  • Start your executable
  • Start “dllinject.exe” (will show up a console window)
  • Get the PID of your executable via Windows Task Manager or Sysinternal Process Exlorer
  • Enter this number in the console black
  • Start profiling