mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
Some performance measurement. Game state copying performance is good.
This commit is contained in:
parent
9a7d158a20
commit
c02d453a4b
3 changed files with 50 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import junit.framework.Assert;
|
|||
import mage.Constants;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.GameImpl;
|
||||
import mage.game.permanent.Permanent;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestBase;
|
||||
|
|
@ -36,5 +37,8 @@ public class LevelUpAbilityTest extends CardTestBase {
|
|||
Assert.assertNotNull(master.getCounters());
|
||||
Assert.assertFalse(master.getCounters().isEmpty());
|
||||
Assert.assertEquals(12, master.getCounters().getCount(CounterType.LEVEL));
|
||||
|
||||
System.out.println("Copy count: " + GameImpl.copyCount);
|
||||
System.out.println("Copy time: " + GameImpl.copyTime + " ms");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package org.mage.test.serverside.performance;
|
||||
|
||||
import mage.game.Game;
|
||||
import org.mage.test.serverside.base.CardTestBase;
|
||||
|
||||
/**
|
||||
* Test for copying game state.
|
||||
*
|
||||
* @ayratn
|
||||
*/
|
||||
public class CopyGameStatePerformanceTest extends CardTestBase {
|
||||
|
||||
public void run() throws Exception {
|
||||
init();
|
||||
reset();
|
||||
System.out.println("Started copying...");
|
||||
long t1 = System.currentTimeMillis();
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Game game = currentGame.copy();
|
||||
Game game2 = game.copy();
|
||||
}
|
||||
long t2 = System.currentTimeMillis();
|
||||
System.out.println("Test took: " + (t2-t1) + " ms");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
CopyGameStatePerformanceTest test = new CopyGameStatePerformanceTest();
|
||||
try {
|
||||
test.run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue