Code Optimisation – Talk

From Bohemia Interactive Community
Revision as of 16:50, 29 May 2010 by Vdmj (talk | contribs)
Jump to navigation Jump to search

This article is brilliant. Thank you --Doolittle 16:57, 28 April 2010 (CEST)

Trust but verify? (C)

It is strange that in the article aren't given the source code of the tests. I myself decided to compare the speed for_from_to_do and while:

#define __prflrStart diag_log "profiler start"; vdmj_diagProfilerTime = diag_ticktime;
#define __prflr(text) diag_log (diag_ticktime - vdmj_diagProfilerTime); diag_log text; vdmj_diagProfilerTime = diag_ticktime;

#define __maxCount 1000000

__prflrStart
__prflr("for begin")

for "_i" from 1 to __maxCount do { };

__prflr("for end")
__prflr("while begin")

_whileCounter = 1;

while { _whileCounter <= __maxCount } do {
    _whileCounter = _whileCounter + 1;
};

__prflr("while end")

1;

usage:

call compile preprocessFileLineNumbers "profiling\loops1.sqf"

output:

"profiler start"
0
"for begin"
0.898438
"for end"
0
"while begin"
0.0351563
"while end"

WTF? I'd like to see in article description of the method of testing, and sqf code of the tests. Thanks

denisko.redisko