| Rev | Line | |
|---|
| [21073] | 1 | function 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 |
|
|---|
| 16 | RandomMapLogger.prototype.printDirectly = function(string)
|
|---|
| 17 | {
|
|---|
| 18 | log(string);
|
|---|
| 19 | print(string);
|
|---|
| 20 | };
|
|---|
| 21 |
|
|---|
| 22 | RandomMapLogger.prototype.print = function(string)
|
|---|
| 23 | {
|
|---|
| 24 | this.printDuration();
|
|---|
| 25 | this.printDirectly(this.prefix + string + "...");
|
|---|
| [22481] | 26 | this.lastTime = Engine.GetMicroseconds();
|
|---|
| [21073] | 27 | };
|
|---|
| 28 |
|
|---|
| 29 | RandomMapLogger.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 |
|
|---|
| 38 | RandomMapLogger.prototype.close = function()
|
|---|
| 39 | {
|
|---|
| 40 | this.printDuration();
|
|---|
| 41 | this.printDurationDirectly(this.prefix + "Total map generation time:", this.startTime);
|
|---|
| 42 | };
|
|---|
| 43 |
|
|---|
| 44 | RandomMapLogger.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.