(tableParser.getIndex() + 20 >= tableString.length())?(tableString.length()-1):(tableParser.getIndex()+20)
)
);
}
IProbabilityFunction ret = null;
try {
try {
// try to guarantee that gc is not called during next compilation
System.gc();
Thread.sleep(1000);
} catch (Exception e) {
fail();
}
// test cache as well
long beforeCompile = System.currentTimeMillis();
ret = tableParser.generateLPD(tableParser.getSSBNNode()); // no cache
long timeToCompile = System.currentTimeMillis() - beforeCompile; // time spent to compile lpd
try {
// try to guarantee that gc is not called during next compilation
System.gc();
Thread.sleep(1000);
} catch (Exception e) {
fail();
}
beforeCompile = System.currentTimeMillis();
IProbabilityFunction cachedRet = tableParser.generateLPD(tableParser.getSSBNNode()); // cache is filled
long timeToGetCache = System.currentTimeMillis() - beforeCompile; // time spent to compile lpd
// the scripts generated by compile or cache should be the same.
assertEquals(ret.toString(), cachedRet.toString());
// cache should be faster
assertTrue("It didn't take less time to use cache. Cache = " + timeToGetCache + "ms, compile = " + timeToCompile + "ms.",
timeToGetCache < timeToCompile);
} catch (MEBNException e) {