Showing posts with label WinAPI. Show all posts
Showing posts with label WinAPI. Show all posts

Monday, April 12, 2010

Performance measurement

My favorite approach to measure performance of my code in AX is WinAPI::getTickCount() method. I find it as the most precise and simple way to do a quick measurement. Code profiler measures performance quite well, however it takes much more time to get the results.
How do you measure performance of your code in AX?

Example:
int timeInterval;
;

timeInterval = WinAPI::getTickCount();
doSomething();
timeInterval = WinAPI::getTickCount() - timeInterval;

Thursday, April 8, 2010

Simple cryptography in AX

There are methods in AX which allow to encrypt and decrypt data easily. Those methods are WinAPIServer::cryptProtectData() for encryption and WinAPIServer::cryptUnProtectData() for decryption. As input and output parameters these methods use CryptoBlob extended data type, which is a container. However, this is not an arbitrary container. It should contain only bytes (integers in the range 0-255). There are methods on the Global class which allow to convert from and to CryptoBlob type, for example, Global::binary2cryptoblob() and Global::cryptoblob2binary().

Sample usage:
public static void cryptoTest()
{
    str text = "Here goes some text";
    CryptoBlob encryptedCryptoBlob;
    str decryptedText;
    ;

    encryptedCryptoBlob = WinAPIServer::cryptProtectData(str2cryptoblob(text));
    conview(encryptedCryptoBlob);
    decryptedText = cryptoblob2str(WinAPIServer::cryptUnProtectData(encryptedCryptoBlob));
    info(decryptedText);
}