]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.tests/src/org/simantics/modeling/tests/commands/AssertMemoryConsumption.java
Small but effective HiDPI fixes for platform G2D
[simantics/platform.git] / bundles / org.simantics.modeling.tests / src / org / simantics / modeling / tests / commands / AssertMemoryConsumption.java
1 package org.simantics.modeling.tests.commands;
2
3 import junit.framework.Assert;
4
5 import org.simantics.db.testing.common.WriteCommand;
6 import org.simantics.modeling.tests.cases.ModelingCommandSequenceTest;
7
8 public class AssertMemoryConsumption extends WriteCommand<ModelingCommandSequenceTest> {
9
10         private int expected;
11         
12         public AssertMemoryConsumption(int expected) {
13                 this.expected = expected;
14         }
15
16         @Override
17         public void run(ModelingCommandSequenceTest environment) throws Exception {
18                 Assert.assertTrue(getUsedMemory() < expected);
19         }
20         
21         private long getUsedMemory() {
22                 
23         System.gc();
24         System.gc();
25         System.gc();
26         Runtime runtime = Runtime.getRuntime();
27         return runtime.totalMemory() - runtime.freeMemory();
28                 
29         }
30
31 }