This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

source: ps/trunk/binaries/data/mods/public/maps/random/rmgen/RandomMapLogger.js

Last change on this file was 23455, checked in by elexis, 5 years ago

Support random map script tests, fixes #4827.

Differential Revision: https://code.wildfiregames.com/D2085
Comments By: wraitii

  • Property svn:eol-style set to native
File size: 1.2 KB
RevLine 
[21073]1function RandomMapLogger()
2{
3 this.lastTime = undefined;
[23455]4 this.startTime = Engine.GetMicroseconds ? Engine.GetMicroseconds() : 0;
[21073]5 this.prefix = ""; // seems noisy
6
[23455]7 // Don't print in test cases
8 if (g_MapSettings.Name)
9 this.printDirectly(
10 this.prefix +
11 "Generating " + g_MapSettings.Name +
12 " of size " + g_MapSettings.Size +
13 " and " + (g_MapSettings.PlayerData.length - 1) + " players.\n");
[21073]14}
15
16RandomMapLogger.prototype.printDirectly = function(string)
17{
18 log(string);
19 print(string);
20};
21
22RandomMapLogger.prototype.print = function(string)
23{
24 this.printDuration();
25 this.printDirectly(this.prefix + string + "...");
[22481]26 this.lastTime = Engine.GetMicroseconds();
[21073]27};
28
29RandomMapLogger.prototype.printDuration = function()
30{
31 if (!this.lastTime)
32 return;
33
34 this.printDurationDirectly("", this.lastTime);
[22481]35 this.lastTime = Engine.GetMicroseconds();
[21073]36};
37
38RandomMapLogger.prototype.close = function()
39{
40 this.printDuration();
41 this.printDurationDirectly(this.prefix + "Total map generation time:", this.startTime);
42};
43
44RandomMapLogger.prototype.printDurationDirectly = function(text, startTime)
45{
[22481]46 this.printDirectly(text + " " + ((Engine.GetMicroseconds() - startTime) / 1000000).toFixed(6) + "s.\n");
[21073]47};
Note: See TracBrowser for help on using the repository browser.