summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7869ee3)
raw | patch | inline | side by side (parent: 7869ee3)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 17 Aug 2017 13:09:15 +0000 (16:09 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 17 Aug 2017 14:41:07 +0000 (17:41 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_map.pas | patch | blob | history | |
src/game/g_window.pas | patch | blob | history | |
src/shared/xprofiler.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index fa9c2883bdd1deed73ae7041b597992ab655f2fa..ff4006bd8dc3f3b154c33fcd2a0ca83e73b94660 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
w: Word;
i, b: Integer;
begin
- g_Map_ProfilersBegin();
-
g_ResetDynlights();
// Ïîðà âûêëþ÷àòü èãðó:
if gExit = EXIT_QUIT then
end;
if gGameOn then g_Weapon_AddDynLights();
-
- g_Map_ProfilersEnd();
end;
procedure g_Game_LoadData();
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index b84bf3aaca6170f165147659879aa9e2971c8f28..77660a8dc3757c0d5b1e50dfb6787478a28f5a84 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
// create sections
if g_profile_collision then
begin
- profMapCollision.sectionBeginAccum('wall coldet');
+ profMapCollision.sectionBegin('wall coldet');
profMapCollision.sectionEnd();
- profMapCollision.sectionBeginAccum('liquid coldet');
+ profMapCollision.sectionBegin('liquid coldet');
profMapCollision.sectionEnd();
end;
end;
diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 045a49ff69cea7a4355e292417fd58edaf07711a..e3226eae84f4e6446f0474434e28d8b81782150c 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
{$IFDEF WINDOWS}Windows,{$ENDIF}
SDL2, GL, GLExt, e_graphics, e_log, g_main,
g_console, SysUtils, e_input, g_options, g_game,
- g_basic, g_textures, e_sound, g_sound, g_menu, ENet, g_net;
+ g_basic, g_textures, e_sound, g_sound, g_menu, ENet, g_net,
+ g_map;
var
h_Wnd: PSDL_Window;
wNeedTimeReset := False;
end;
+ g_Map_ProfilersBegin();
+
t := Time_Delta div 28{(27777 div 1000)};
if t > 0 then
begin
else if NetMode = NET_CLIENT then g_Net_Client_Update();
end;
+ g_Map_ProfilersEnd();
+
if wLoadingQuit then
begin
g_Game_Free();
index 083704863848142f8e7f8342f3c57a260d1e9959..ac9b54bd4267fde25ed2112560ee92ccfccda20c 100644 (file)
--- a/src/shared/xprofiler.pas
+++ b/src/shared/xprofiler.pas
*)
// stopwatch timer to measure short periods (like frame rendering phases)
{$INCLUDE a_modes.inc}
+{.$DEFINE XPROFILER_SLOW_AVERAGE}
unit xprofiler;
interface
const
- TProfHistorySize = 100;
+ TProfHistorySize = 1000;
type
TProfilerBar = record
private
history: array [0..TProfHistorySize-1] of Integer; // circular buffer
- hisHead: Integer;
- curval: Single;
+ hisLast: Integer;
+ //curval: Single;
+ curAccum: UInt64;
+ curAccumCount: Integer;
mName: AnsiString;
mLevel: Integer;
// ////////////////////////////////////////////////////////////////////////// //
-procedure TProfilerBar.initialize (); begin hisHead := -1; curval := 0; end;
+procedure TProfilerBar.initialize (); begin hisLast := -1; curAccum := 0; curAccumCount := 0; end;
procedure TProfilerBar.update (val: Integer);
var
idx: Integer;
begin
if (val < 0) then val := 0; //else if (val > 1000000) val := 1000000;
- if (hisHead = -1) then begin hisHead := 0; curval := 0; for idx := 0 to TProfHistorySize-1 do history[idx] := val; end;
- history[hisHead] := val;
- Inc(hisHead);
- if (hisHead = TProfHistorySize) then hisHead := 0;
- curval := FilterFadeoff*val+(1.0-FilterFadeoff)*curval;
+ if (hisLast = -1) then begin hisLast := TProfHistorySize-1; curAccum := 0; curAccumCount := 0; for idx := 0 to TProfHistorySize-1 do history[idx] := val; end;
+ if (curAccumCount = TProfHistorySize) then Dec(curAccum, UInt64(history[(hisLast+1) mod TProfHistorySize])) else Inc(curAccumCount);
+ Inc(hisLast);
+ if (hisLast >= TProfHistorySize) then hisLast := 0;
+ Inc(curAccum, UInt64(val));
+ history[hisLast] := val;
+ //curval := FilterFadeoff*val+(1.0-FilterFadeoff)*curval;
end;
function TProfilerBar.getvalue (): Integer;
-//var idx: Integer;
+{$IFDEF XPROFILER_SLOW_AVERAGE}
+var idx: Integer;
+{$ENDIF}
begin
- result := round(curval);
- {
+ {$IFDEF XPROFILER_SLOW_AVERAGE}
result := 0;
for idx := 0 to TProfHistorySize-1 do Inc(result, history[idx]);
result := result div TProfHistorySize;
- }
+ {$ELSE}
+ //result := round(curval);
+ if curAccumCount > 0 then result := Integer(curAccum div curAccumCount) else result := 0;
+ {$ENDIF}
end;
function TProfilerBar.getcount (): Integer; begin result := TProfHistorySize; end;
function TProfilerBar.getvalat (idx: Integer): Integer;
begin
- if (idx < 0) or (idx >= TProfHistorySize) then result := 0 else result := history[(hisHead-idx-1+TProfHistorySize*2) mod TProfHistorySize];
+ if (idx < 0) or (idx >= TProfHistorySize) then result := 0 else result := history[(hisLast-idx+TProfHistorySize*2) mod TProfHistorySize];
end;