Jibble

Author Topic: Interesting article on using chrome://tracing/  (Read 1186 times)

eri0o

Interesting article on using chrome://tracing/
« on: 05 Feb 2020, 02:44 »
https://www.gamasutra.com/view/news/176420/Indepth_Using_Chrometracing_to_view_your_inline_profiling_data.php | webarchive link

Quote
In-depth: Using Chrome://tracing to view your inline profiling data

If you have an inline profiling system, with some slight modifications, you can view that data in the Chrome web browser rather than writing a visualization tool yourself.

Having a nice graphical representation of profiling data is crucial to finding critical hotspots in a realtime application. Creating a viewer application for that custom data is a massive time sink, so before you start writing ones, know your options.

Getting started with profiling your game...

If you are using a Google Chrome / Chromium browser, you can click the link chrome://tracing/, to open an already included profiling tool - you need to copy and paste it into your address bar since the forums automatically add http to the link, and it's not an http link. I found the above article very interesting on how to use it offline on your game to visualize system bottlenecks by producing a json file with a predefined structured. This may be useful to someone else, so I am leaving it linked here.
« Last Edit: 05 Feb 2020, 02:46 by eri0o »

Mandle

  • NO PIXEL LEFT BEHIND!!!
    • Mandle worked on one or more games that won an AGS Award!
    •  
    • Mandle worked on one or more games that was nominated for an AGS Award!
Re: Interesting article on using chrome://tracing/
« Reply #1 on: 05 Feb 2020, 10:18 »
I understood some of those words.

eri0o

Re: Interesting article on using chrome://tracing/
« Reply #2 on: 05 Feb 2020, 10:25 »
I was feeling lonely, sorry  :embarrassed:

Mandle

  • NO PIXEL LEFT BEHIND!!!
    • Mandle worked on one or more games that won an AGS Award!
    •  
    • Mandle worked on one or more games that was nominated for an AGS Award!
Re: Interesting article on using chrome://tracing/
« Reply #3 on: 05 Feb 2020, 22:50 »
I was feeling lonely, sorry  :embarrassed:

Hey, I was just kidding, man. Buck up! Dry those eyes, my friend. There are many people here a LOT more technically savvy than me who will find this valuable.  ;)

Monsieur OUXX

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    •  
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
Re: Interesting article on using chrome://tracing/
« Reply #4 on: 06 Feb 2020, 15:52 »
I don't understand : Does this apply to AGS?


EDIT: Oh yes, yes it does! And I already have the logging module ;)
« Last Edit: 06 Feb 2020, 15:58 by Monsieur OUXX »
 

Wyz

  • anno 1986
    • I can help with making music
    • I can help with story design
    • I can help with translating
    • I can help with voice acting
    • I can help with web design
    • Wyz worked on one or more games that won an AGS Award!
    •  
    • Wyz worked on one or more games that was nominated for an AGS Award!
Re: Interesting article on using chrome://tracing/
« Reply #5 on: 06 Feb 2020, 20:51 »
Ah yes, that is quite useful indeed! :-D
I use it to inspect the profiling reports I get from gprof more easily. It nice to have that already built-in your browser. (nod)
Life is like an adventure without the pixel hunts.

eri0o

Re: Interesting article on using chrome://tracing/
« Reply #6 on: 10 Feb 2020, 13:28 »
Awesome you guys found it interesting :)

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: Interesting article on using chrome://tracing/
« Reply #7 on: 11 Feb 2020, 10:02 »
I don't understand : Does this apply to AGS?


EDIT: Oh yes, yes it does! And I already have the logging module ;)


Please explain. How would you performance-profile an AGS game?

Monsieur OUXX

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    •  
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
Re: Interesting article on using chrome://tracing/
« Reply #8 on: 11 Feb 2020, 14:32 »
I don't understand : Does this apply to AGS?


EDIT: Oh yes, yes it does! And I already have the logging module ;)


Please explain. How would you performance-profile an AGS game?

I was mistaken. This does not apply to AGS. At least for performance. For a moment there I thought it could be useful to visualize stuff like "how much time does my tester spend in that room?" if you write it into a Json file during the game session.
 

eri0o

Re: Interesting article on using chrome://tracing/
« Reply #9 on: 17 Feb 2021, 22:09 »
So, I did endup using today. It requires a very high resolution Timer for it to work, I think in Microseconds, and AGS doesn't have one. I tried to use a music clip that would give me a milissecond timer and Chrome just crashes if begin and end time of the same event matches (which is just unfortunately).

profiler.ash
Code: Adventure Game Studio
  1. // Profiler module header
  2. import void InitProfiler();
  3. import void CloseProfiler();
  4. import void pro(const string cat, const string name, const string ph);

profiler.asc
Code: Adventure Game Studio
  1. // Profiler module script
  2.  
  3. File* pf;
  4. AudioChannel* time;
  5. int ts;
  6. void InitProfiler()
  7. {
  8.   time = aRain_calm.Play(eAudioPriorityHigh, eRepeat);
  9.   pf = File.Open("$SAVEGAMEDIR$/profile.json",eFileWrite);
  10.   pf.WriteRawLine("[\n");
  11.   pf.Close();
  12.   pf = File.Open("$SAVEGAMEDIR$/profile.json",eFileAppend);
  13. }
  14.  
  15. void CloseProfiler()
  16. {
  17.   pf.WriteRawLine("\n]");
  18.   pf.Close();
  19. }
  20.  
  21. void pro(const string cat, const string name, const string ph)
  22. {
  23.   ts = DateTime.Now.RawTime;
  24.  
  25.   if(pf)
  26.     pf.WriteRawLine(
  27.       String.Format("{\"cat\": \"%s\", \"pid\": 1, \"tid\": 1, \"ts\": %d, \"ph\": \"%s\", \"name\": \"%s\", \"args\": {} },\n",
  28.         cat, ts, ph, name));
  29. }

Then on your code you use like this

Code: Adventure Game Studio
  1. #define PRO
  2.  
  3. void my_func() {
  4. #ifdef PRO
  5. pro("my","func","B");
  6. #endif
  7.   // things inside my function I wish to measure
  8. #ifdef PRO
  9. pro("my","func","E");
  10. #endif
  11. }
  12.  

The preprocessor Macro is so you can turn off it easily.

On your game save directory, this will generate a profile.json file. If you force close, you need to open with a text editor and terminate it with a ].

But for the code above to work I had to hack ags datetime.cpp and force it return me time in microsseconds.

Code: C++
  1. int DateTime_GetRawTime(ScriptDateTime *sdt) {
  2.     return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::
  3.         now().time_since_epoch()).count();
  4.     //return sdt->rawUnixTime;
  5. }

But in the end I discovered the Chrome profile is not very good and it's suuuuper slow and doesn't give any meaningful statistics.