PDA

View Full Version : [SOLVED]Strange misterious load time using FPC



arthurprs
11-09-2007, 09:15 PM
procedure GameINIT(const Size, bombs: Word);
var
a, b: Cardinal;
begin
a := GetTickCount;
BASSinit;
SDLinit; // SDL loaded, icon loaded and screen initialized here
minefield := TMineField.create(Size, bombs);
Loadresources; // files loaded from zip here

b := GetTickCount;

minefield.create2;

Writeln(Format('%ums for minefield create2', [GetTickCount - b]));

b := GetTickCount;

font := Tbitmapfont.Create('font\monospac821a.xml');

Writeln(Format('%ums for font loading', [GetTickCount - b]));

Writeln(Format('%ums to gameINIT', [GetTickCount - a]));
end;

//...
GameINIT(15, 40);
//...

Compiled with FPC 2.2.0
http://img502.imageshack.us/img502/4557/capture11092007180936tz0.th.png (http://img502.imageshack.us/img502/4557/capture11092007180936tz0.png)

Compiled with D7
http://img502.imageshack.us/img502/6185/capture11092007180931dh3.th.png (http://img502.imageshack.us/img502/6185/capture11092007180931dh3.png)

Game including a bin from FPC and D7 here ~550kb (http://www.mediafire.com/?9ihicjjypjf)

Look the HUGE misterious load time :? :?

This is a study game, im making it for learning {i already learned a lot},
i will try make it multiplayer

A very test release and
don't expect good graphics yet :P

Setharian
12-09-2007, 03:36 PM
Is the speed difference the same (or nearly same) every time you run those 2 executables? If yes then there can be 3 culprits - LoadResources, Writeln and Format.

arthurprs
13-09-2007, 02:13 AM
Is the speed difference the same (or nearly same) every time you run those 2 executables? If yes then there can be 3 culprits - LoadResources, Writeln and Format.
Yes, the speed is similar in every run

Removed the lines and program still vry slow to load ;/

Setharian
13-09-2007, 06:30 AM
There's also "TMineField.Create(Size, bombs)" statement but I don't think it would cause such a delay (depends on the contents of the constructor). Just time every statement with GetTickCount and you'll find out which statement is so much slower with FPC.

arthurprs
14-09-2007, 06:05 PM
There's also "TMineField.Create(Size, bombs)" statement but I don't think it would cause such a delay (depends on the contents of the constructor). Just time every statement with GetTickCount and you'll find out which statement is so much slower with FPC.

Yeah you have reason the huge load time is on TMineField.Create,

i will time the constructor to see what is making this

arthurprs
14-09-2007, 06:28 PM
Solved

The problem is many calls Randomize; that is extremelly slow on FPC.
now only one call :?

Robert Kosek
14-09-2007, 07:27 PM
Huh, strange. It might be faster to save the random seed, change it to the UTC time (as a longword) and then modify that number by a random integer. :D

arthurprs
14-09-2007, 08:37 PM
Huh, strange. It might be faster to save the random seed, change it to the UTC time (as a longword) and then modify that number by a random integer. :D
thx i used google and found some info,
im using this way
DecodeTime(Time,seed,seed,seed,seed);
RandSeed := seed;

tnx for all