mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Use the profiler to profile map generation
Instead of writing the duration to the console it uses `Engine.ProfileStart` and `Engine.ProfileStop` to profile map generation. Refs: #5263
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
function RandomMapLogger()
|
function RandomMapLogger()
|
||||||
{
|
{
|
||||||
this.lastTime = undefined;
|
this.taskStarted = false;
|
||||||
this.startTime = Engine.GetMicroseconds ? Engine.GetMicroseconds() : 0;
|
this.startTime = Engine.GetMicroseconds ? Engine.GetMicroseconds() : 0;
|
||||||
this.prefix = ""; // seems noisy
|
this.prefix = ""; // seems noisy
|
||||||
|
|
||||||
@@ -21,27 +21,18 @@ RandomMapLogger.prototype.printDirectly = function(string)
|
|||||||
|
|
||||||
RandomMapLogger.prototype.print = function(string)
|
RandomMapLogger.prototype.print = function(string)
|
||||||
{
|
{
|
||||||
this.printDuration();
|
if (this.taskStarted)
|
||||||
this.printDirectly(this.prefix + string + "...");
|
Engine.ProfileStop();
|
||||||
this.lastTime = Engine.GetMicroseconds();
|
|
||||||
};
|
|
||||||
|
|
||||||
RandomMapLogger.prototype.printDuration = function()
|
const text = this.prefix + string;
|
||||||
{
|
this.printDirectly(text + "...\n");
|
||||||
if (!this.lastTime)
|
Engine.ProfileStart(text);
|
||||||
return;
|
this.taskStarted = true;
|
||||||
|
|
||||||
this.printDurationDirectly("", this.lastTime);
|
|
||||||
this.lastTime = Engine.GetMicroseconds();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RandomMapLogger.prototype.close = function()
|
RandomMapLogger.prototype.close = function()
|
||||||
{
|
{
|
||||||
this.printDuration();
|
if (this.taskStarted)
|
||||||
this.printDurationDirectly(this.prefix + "Total map generation time:", this.startTime);
|
Engine.ProfileStop();
|
||||||
};
|
this.printDirectly(this.prefix + "Map generation finished.\n");
|
||||||
|
|
||||||
RandomMapLogger.prototype.printDurationDirectly = function(text, startTime)
|
|
||||||
{
|
|
||||||
this.printDirectly(text + " " + ((Engine.GetMicroseconds() - startTime) / 1000000).toFixed(6) + "s.\n");
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user