Code Optimisation – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
This article is brilliant. Thank you --[[User:Doolittle|Doolittle]] 16:57, 28 April 2010 (CEST)
This article is brilliant. Thank you --[[User:Doolittle|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
[[User:DenV|denisko.redisko]]

Revision as of 15:50, 29 May 2010

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