shadowrecon Posted April 5, 2012 Share Posted April 5, 2012 So ive been working on this lib and trying to do comparisons with the amount of time the function takes depending on what i change. my problem is i get a bunch of different numbers and some are consistent but i also get 0 ms which would main the function ran in nano seconds, which is cool if it actually worked that way but i wanted to see if i have this setup correctly to time the function. [scar] program New; {$L GMRL_Plugin.dll} Procedure TestBitmapFunctions; Var BMP,T,C: Integer; HWDC: LongWord; begin bmp := BitmapFromString(50, 50, 'ceNrtl/1PGnccx/mHbPqvm' + 'Oiy2Jg99IclS9eB0bo1y8piE12y1geg4EStqGUzWtFbGT4iiojaF' + 'rVMvTuhCMfzxCtwdxzenftwMosWKJhG24TL64dvDr7fe9378/neg' + 'XPD7qxQ4fJBZNevyYxXcl1J7lHVjLxjdep2YckzE0ebr1U1K4suh' + 'ZTz6cWjE02QkhfJ+53cAN9mBStnz11vGi1XzNhUlZ2lrM4McvPPL' + 'RMiy1PBzDfbayWSWuUHraAoI6lph4G6Rlw8uxRcq1p9Jp/2/Fnln' + 'vmAVlkBCFzUOF35TFefM7wEK0hJbPKa9jwrv7+v4KaynQnNIDlnd' + 'Xo7Fyviud7I7Zb3PhnE6Zmurqk+d0fQFRfr9pwink3j3M76uB/gk' + 'neOT/cqFSoUAt/drJCLXC6vWF2hlW5ytUu/0qiwftVmqb+/UNey0' + 'KB2nNCo2bjz+2ZTt+Nmm+UHtXV8Zu3SrH4bsr0Os0CaE1jgSKBSP' + 'ElxcZqDMZx5Q3FuP2ndCsj71/8w2i/H6nbHEig9sZKsaKUYRxMMB' + '1Y0y4MnxfLR+FEglna4E5vu+M22hbKs9u13RX7ELbfwbRu+vfqWn' + 'VVsZ6PQxK/bFt1hdnjxEAQAsAIlEDvJ7ZDigofpQIzVmSP/eJN1v' + '8yVZXUsCBmOBY4lfest+//j23jodXRiL/WFJkIv4cHU8GIMBACla' + 'MWkBQgqyfBhEoJiiQN2YD685Iw1qJ6XZZUKTabCs2xkWeCSgsAIP' + 'EBlxnDfFInN3So0EdobDTJDllgkfgRAvRIMD0ExrHAQ506UgMdzI' + 'fPWvzLVellWTBChvfo4piZxTdIzkvQ8Sbp1CVd/wqWF9DDTjUITY' + 'a/tEhkrqB2gMqAaBO9G8EcT2MmZE/qm/bOOiEy5VpZVwjVKOntZE' + 'hV4WgyKPs0Kyooai1ltE/SgOaoTGcwSGZiPPJ4L98+G+maC2ulA3' + '3TQtB6UKexl9hV7zKfAh2eJdOwvNjrChvtTARVDPOAZHzpRV8TK6' + 'aXPKkVBaWAuDFXrmwmBT++Uv3eKeGb3SxUrZVlxyZdcfPnocJqNP' + 'mXDg2xQkyIeMt77jOcnnnGjY8WstjyULptVJBsUKM2G+meDoKSdI' + 'rQmosfkNVi90i5b6VavNtaOSHM69iwTUQgiUjC+X5l9Of36DuW6z' + 'dE4qi9m5XAndfNR2HRF6DZ6xiweaae1dCvD+Ej6YJKN6NmQNuXvY' + 'nytjOdn2t1I7X1H4d9wNIYOFbRqVDteuJJQMth3o6868wIPLjXi+' + 'tPsknaUYTVhGGMCM4zfyBAGxjdC7w/TngHKo6XcGsr1KB5YxnT1B' + 'a00jud4QidaOYNbeQEr1cSefgaXdiyWbvV0bGRXW5ufnlq093MMa' + 'S1kdaPFvIbFdfPh4lkpxrHBKfSzu4bSrRbmTRd+D377wGLbeWPbJ' + 'ov31aAJHfh79ws5cjlvZ4V+5V6P9ctWc4PqRYNqHZ7eMuWqVGGXK' + 'mzSrmVob2nH0vcdi5BS/b2Jpk5T5bdoxerKqfwj/tQJEXsVSkTyU' + 'R4fZ1/9B0twddM='); HWDC := GetBitmapDC(BMP); Writeln('Starting Bitmap Test.'); Repeat // repeats 10 times so i can get an average time T := GetSystemTime; GMRL__FastMakeMapBoxes(HWDC); // This makes the 50 x 50 bmp pixelated (5 x 5) squares of the average color Writeln('Time taken: '+IntToStr(GetSystemTime - T)+' ms.'); Inc©; until C = 10; Debugbitmap(BMP); end; [/scar] Debug: Starting Bitmap Test.Time taken: 16 ms.Time taken: 0 ms.Time taken: 16 ms.Time taken: 0 ms.Time taken: 15 ms.Time taken: 0 ms.Time taken: 0 ms.Time taken: 15 ms.Time taken: 0 ms.Time taken: 16 ms.Successfully executed (125.9964 ms)[/Code] Quote Link to comment Share on other sites More sharing options...
Wanted Posted April 5, 2012 Share Posted April 5, 2012 repeat it 100 times and divide the time taken by 100. do by 1000 or more if you have to. Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted April 5, 2012 Author Share Posted April 5, 2012 (edited) repeat it 100 times and divide the time taken by 100. do by 1000 or more if you have to. Alright thats sounds like a good idea. Edit: Whats weird is i ran it 1000 times but ended up with less than 16ms the average was 5ms. Is my computer causing the in consistency or could it be a code problem? I know its only 10 ms here and there but im just curious why im not getting consistent results. New Code: [scar] program New; {$L GMRL_Plugin.dll} Procedure TestBitmapFunctions; Var BMP,T,C: Integer; HWDC: LongWord; begin bmp := BitmapFromString(50, 50, 'ceNrtl/1PGnccx/mHbPqvm' + 'Oiy2Jg99IclS9eB0bo1y8piE12y1geg4EStqGUzWtFbGT4iiojaF' + 'rVMvTuhCMfzxCtwdxzenftwMosWKJhG24TL64dvDr7fe9378/neg' + 'XPD7qxQ4fJBZNevyYxXcl1J7lHVjLxjdep2YckzE0ebr1U1K4suh' + 'ZTz6cWjE02QkhfJ+53cAN9mBStnz11vGi1XzNhUlZ2lrM4McvPPL' + 'RMiy1PBzDfbayWSWuUHraAoI6lph4G6Rlw8uxRcq1p9Jp/2/Fnln' + 'vmAVlkBCFzUOF35TFefM7wEK0hJbPKa9jwrv7+v4KaynQnNIDlnd' + 'Xo7Fyviud7I7Zb3PhnE6Zmurqk+d0fQFRfr9pwink3j3M76uB/gk' + 'neOT/cqFSoUAt/drJCLXC6vWF2hlW5ytUu/0qiwftVmqb+/UNey0' + 'KB2nNCo2bjz+2ZTt+Nmm+UHtXV8Zu3SrH4bsr0Os0CaE1jgSKBSP' + 'ElxcZqDMZx5Q3FuP2ndCsj71/8w2i/H6nbHEig9sZKsaKUYRxMMB' + '1Y0y4MnxfLR+FEglna4E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); Writeln('Starting Bitmap Test.'); T := GetSystemTime; Repeat GMRL__FastMakeMapBoxes(HWDC); Inc©; until C = 1000; Writeln('Avrage Time taken: '+IntToStr((GetSystemTime - T) div 1000)+' ms.'); Debugbitmap(BMP); end; [/scar] new Debug: Successfully compiled (34.106 ms)Starting Bitmap Test.Avrage Time taken: 5 ms.Successfully executed (5934.8199 ms)[/Code] Edited April 5, 2012 by shadowrecon Quote Link to comment Share on other sites More sharing options...
Wanted Posted April 5, 2012 Share Posted April 5, 2012 Use FloatToStr( with / instead div with IntToStr to get a more accurate result Also unless you used this one advanced method I forgot what it was, you can only be accurate to 15~16ms in SCAR. Quote Link to comment Share on other sites More sharing options...
FHannes Posted April 5, 2012 Share Posted April 5, 2012 GetSystemTime is very inaccurate for timing. http://forums.scar-divi.com/showthread.php?463-system-time-quantization Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted April 5, 2012 Author Share Posted April 5, 2012 Thanks, thats what i was looking for. Quote Link to comment Share on other sites More sharing options...