patch: performance meter

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
User avatar
skidd13
OpenTTD Developer
OpenTTD Developer
Posts: 522
Joined: 03 Mar 2005 10:49
Location: Germany

patch: performance meter

Post by skidd13 »

I've been working on a patch to get a impression of the current performance of the code (for developers who want to optimize their code) and for normal users to get their FPS (TPS (Realtime) ≙ FPS). The initial design has been made by Zojj due to testing his "simplified realistic acceleration" patch.

[list]Changelog
[*]Overtake Zojj's patch
[*]Moved the the globals to a struct
[*]Optimisation & simplification of code
[*]More comments
[*]Start/stop button
[*]Sticky button
[*]Split the code off from the main gui to it's own files
[*]Toolbar entry
[*]Shortcut [alt]+[ctrl]+[p]
[*]Added type timestamp
[*]Moved code to C++
[*]Added switch for realtime/cputime[/list]
  • Different modes:
  • Ticks/Frames per second realtime (This value has influences from the environment)
  • Ticks per second CPU time (Here is only the time counted on which the process runs on the CPU / environment independent)
  • CPU cycles per code call (take a look at town_cmd.cpp how to use the stuff)
If you want to use the patch don't forget to replace your openttd.grf with the attatched one.

Thanks to B. N. SmatZ! for debuging my code.
:bow: Big thanks to KUDr for improving my programming skills.
Attachments
Unnamed, 4th Apr 2071.png
Unnamed, 4th Apr 2071.png (90.27 KiB) Viewed 5906 times
openttd.grf
(29.26 KiB) Downloaded 174 times
performance_meter_r10827.patch
(31.66 KiB) Downloaded 201 times
Last edited by skidd13 on 08 Aug 2007 20:15, edited 10 times in total.
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: patch: performance meter

Post by Bilbo »

Hmmm ... I wonder it it would be possible to add also frames per second indicator there. Or is 1 frame always equal to 1 tick?
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
User avatar
skidd13
OpenTTD Developer
OpenTTD Developer
Posts: 522
Joined: 03 Mar 2005 10:49
Location: Germany

Re: patch: performance meter

Post by skidd13 »

Bilbo wrote:Hmmm ... I wonder it it would be possible to add also frames per second indicator there. Or is 1 frame always equal to 1 tick?
1 tick includes AFAIK 1 redraw, so it should be the same.
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: patch: performance meter

Post by Bilbo »

skidd13 wrote:
Bilbo wrote:Hmmm ... I wonder it it would be possible to add also frames per second indicator there. Or is 1 frame always equal to 1 tick?
1 tick includes AFAIK 1 redraw, so it should be the same.
Hmm .. so maybe I thought of one improvement for OpenTTD. When in fast forward mode, do not draw more than X frames per second. Humans can't distinguish between 120 and 1200 fps anyway, especially if they have 60Hz LCD panel :)

So perhaps add code like "if time from last frame was less than 1/X, skip drawing :)".
This may be useful, as it will make the fast forward mode even faster :)
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
User avatar
skidd13
OpenTTD Developer
OpenTTD Developer
Posts: 522
Joined: 03 Mar 2005 10:49
Location: Germany

Re: patch: performance meter

Post by skidd13 »

Bilbo wrote:
skidd13 wrote:
Bilbo wrote:Hmmm ... I wonder it it would be possible to add also frames per second indicator there. Or is 1 frame always equal to 1 tick?
1 tick includes AFAIK 1 redraw, so it should be the same.
Hmm .. so maybe I thought of one improvement for OpenTTD. When in fast forward mode, do not draw more than X frames per second. Humans can't distinguish between 120 and 1200 fps anyway, especially if they have 60Hz LCD panel :)

So perhaps add code like "if time from last frame was less than 1/X, skip drawing :)".
This may be useful, as it will make the fast forward mode even faster :)
I discussed that with B. N. SmatZ too (IIRC it was him). But only one step by one. ;)
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: patch: performance meter

Post by Mchl »

How about having also min and max t/s apart from current and average values?

These are useful. If your min and max stay close to average, then your perfomance is steady. On the other hand, when they're spread apart your game may be quite a strange experience.
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: patch: performance meter

Post by Bilbo »

Ok, when I tried it, it won't compile with mingw + msys:

[SRC] Compiling performance_gui.cpp
e:/p/svn.openttd.org/trunk/src/performance_gui.cpp: In function `timestamp GetTimestamp()':
e:/p/svn.openttd.org/trunk/src/performance_gui.cpp:60: error: `SYSTEMTIME' undeclared (first use this function)
e:/p/svn.openttd.org/trunk/src/performance_gui.cpp:60: error: (Each undeclared identifier is reported only once for each function it appears in.)
e:/p/svn.openttd.org/trunk/src/performance_gui.cpp:60: error: expected `;' before "st"
e:/p/svn.openttd.org/trunk/src/performance_gui.cpp:61: error: `st' undeclared (first use this function)
e:/p/svn.openttd.org/trunk/src/performance_gui.cpp:61: error: `GetSystemTime' undeclared (first use this function)
make[1]: *** [performance_gui.o] Error 1
make[1]: Leaving directory `/e/p/svn.openttd.org/trunk/objs/release'

When I replaced body of GetTimestamp() with following line:

return ((clock() * 1000) / CLOCKS_PER_SEC);

it compiled fine.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
User avatar
skidd13
OpenTTD Developer
OpenTTD Developer
Posts: 522
Joined: 03 Mar 2005 10:49
Location: Germany

Re: patch: performance meter

Post by skidd13 »

Bilbo wrote:Ok, when I tried it, it won't compile with mingw + msys:

When I replaced body of GetTimestamp() with following line:

return ((clock() * 1000) / CLOCKS_PER_SEC);

it compiled fine.
The patch is a bit outdated for now. I'm working on it. The systemtime is something done by Zojj. It'll be replaced with the clock thing in the next version.
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: patch: performance meter

Post by Bilbo »

Also, I noticed one a bit weird thing, when not using fast forward, the "current" reads 40 ticks/s (though it ocassionaly flips to 30 or 50) but average says 31.3 /s :) Perhaps a bit inconsistent :)
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
User avatar
skidd13
OpenTTD Developer
OpenTTD Developer
Posts: 522
Joined: 03 Mar 2005 10:49
Location: Germany

Re: patch: performance meter

Post by skidd13 »

Bilbo wrote:Also, I noticed one a bit weird thing, when not using fast forward, the "current" reads 40 ticks/s (though it ocassionaly flips to 30 or 50) but average says 31.3 /s :) Perhaps a bit inconsistent :)
To have a correct measure you need a full load CPU. If you have huge games like the ones from the coop server you'll get even without FF to full CPU load.

[EDIT]Patch updated again.[/EDIT]
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
l_Blue_l
Transport Coordinator
Transport Coordinator
Posts: 285
Joined: 29 Mar 2006 22:42
Contact:

Re: patch: performance meter

Post by l_Blue_l »

i have so needed this to test some patches of mine. Great work to all involved. Just wondering what about a way to time how long a single operation takes and produce a log file.

Edit: There allready is i just didnt know about it.
Last edited by l_Blue_l on 28 Jul 2007 08:27, edited 1 time in total.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1729
Joined: 30 Mar 2005 09:43

Re: patch: performance meter

Post by peter1138 »

The TIC() and TOC(s, n) macros have existed for just that purpose for a long time...
He's like, some kind of OpenTTD developer.
l_Blue_l
Transport Coordinator
Transport Coordinator
Posts: 285
Joined: 29 Mar 2006 22:42
Contact:

Re: patch: performance meter

Post by l_Blue_l »

:roll: well silly me then. Thanks for letting me know. I will have to give it a try sometime
User avatar
skidd13
OpenTTD Developer
OpenTTD Developer
Posts: 522
Joined: 03 Mar 2005 10:49
Location: Germany

Re: patch: performance meter

Post by skidd13 »

Patch updated with a new type CPU cycles per code call. To use this type check town_cmd.cpp in the diff. Then remove the edits from there and add them there where you want to test your code. Happy benchmarks. ;)

[EDIT] Patch updated. Last version had a few bugs. Sorry
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 10 guests