fix stream row calculation

This commit is contained in:
Eyck Jentzsch 2021-01-15 08:53:06 +01:00
parent a42f086339
commit bca94ceb9d
6 changed files with 22 additions and 46 deletions

View File

@ -40,10 +40,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
TreeMap<Long, IEvent[]> events = new TreeMap<>(); TreeMap<Long, IEvent[]> events = new TreeMap<>();
/** The max concurrency. */ /** The max concurrency. */
private int maxConcurrency = 0; private int rowCount = -1;
/** The concurrency calculated. */
boolean concurrencyCalculated = false;
/** /**
* Instantiates a new abstract tx stream. * Instantiates a new abstract tx stream.
@ -137,21 +134,21 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
*/ */
@Override @Override
public int getRowCount() { public int getRowCount() {
if (!concurrencyCalculated) if (rowCount<0)
calculateConcurrency(); calculateConcurrency();
return maxConcurrency; return rowCount;
} }
/** /**
* Calculate concurrency. * Calculate concurrency.
*/ */
public void calculateConcurrency() { void calculateConcurrency() {
if (concurrencyCalculated) if (rowCount>=0)
return; return;
ArrayList<Long> rowEndTime = new ArrayList<>(); ArrayList<Long> rowEndTime = new ArrayList<>();
HashMap<Long, Integer> rowByTxId = new HashMap<>(); HashMap<Long, Integer> rowByTxId = new HashMap<>();
events.entrySet().stream().forEach(entry -> { for(Entry<Long, IEvent[]> entry: events.entrySet()) {
Arrays.asList(entry.getValue()).stream().forEach(evt -> { for(IEvent evt:entry.getValue()) {
TxEvent txEvt = (TxEvent) evt; TxEvent txEvt = (TxEvent) evt;
ITx tx = txEvt.getTransaction(); ITx tx = txEvt.getTransaction();
int rowIdx = 0; int rowIdx = 0;
@ -179,10 +176,9 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
rowByTxId.put(tx.getId(), rowIdx); rowByTxId.put(tx.getId(), rowIdx);
break; break;
} }
}); }
}); }
maxConcurrency=rowEndTime.size(); rowCount=rowEndTime.size()>0?rowEndTime.size():1;
concurrencyCalculated = true;
getChildNodes().parallelStream().forEach(c -> ((TxGenerator)c).calculateConcurrency()); getChildNodes().parallelStream().forEach(c -> ((TxGenerator)c).calculateConcurrency());
} }

View File

@ -420,16 +420,13 @@ public class TextDbLoader implements IWaveformDbLoader {
TxGenerator gen = loader.txGenerators.get(scvTx.generatorId); TxGenerator gen = loader.txGenerators.get(scvTx.generatorId);
TxStream stream = loader.txStreams.get(gen.stream.getId()); TxStream stream = loader.txStreams.get(gen.stream.getId());
if (scvTx.beginTime == scvTx.endTime) { if (scvTx.beginTime == scvTx.endTime) {
TxEvent evt = new TxEvent(loader, EventKind.SINGLE, id, scvTx.beginTime); stream.addEvent(new TxEvent(loader, EventKind.SINGLE, id, scvTx.beginTime));
stream.addEvent(evt); gen.addEvent(new TxEvent(loader, EventKind.SINGLE, id, scvTx.beginTime));
gen.addEvent(evt);
} else { } else {
TxEvent begEvt = new TxEvent(loader, EventKind.BEGIN, id, scvTx.beginTime); stream.addEvent(new TxEvent(loader, EventKind.BEGIN, id, scvTx.beginTime));
stream.addEvent(begEvt); gen.addEvent(new TxEvent(loader, EventKind.BEGIN, id, scvTx.beginTime));
gen.addEvent(begEvt); stream.addEvent(new TxEvent(loader, EventKind.END, id, scvTx.endTime));
TxEvent endEvt = new TxEvent(loader, EventKind.END, id, scvTx.endTime); gen.addEvent(new TxEvent(loader, EventKind.END, id, scvTx.endTime));
stream.addEvent(endEvt);
gen.addEvent(endEvt);
} }
if (nextLine != null && nextLine.charAt(0) == 'a') { if (nextLine != null && nextLine.charAt(0) == 'a') {
int idx = 0; int idx = 0;

View File

@ -83,13 +83,4 @@ class TxGenerator extends AbstractTxStream {
return stream.getKind(); return stream.getKind();
} }
/**
* Gets the width.
*
* @return the width
*/
@Override
public int getRowCount() {
return stream.getRowCount();
}
} }

View File

@ -118,8 +118,4 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
return "signal"; return "signal";
} }
@Override
public void calculateConcurrency() {
}
} }

View File

@ -79,8 +79,4 @@ public interface IWaveform extends IHierNode {
*/ */
public int getRowCount(); public int getRowCount();
/**
* Calculate the concurrency (th enumber of parallel ongoing events) of the waveform.
*/
public void calculateConcurrency();
} }

View File

@ -19,18 +19,18 @@
<booleanAttribute key="includeOptional" value="true"/> <booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> <stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.minres.scviewer.database.test"/> <listEntry value="/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java"/>
</listAttribute> </listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/> <listEntry value="1"/>
</listAttribute> </listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.minres.scviewer.database.test"/> <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> <booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> <stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> <stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/> <booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.minres.scviewer.database.test.DatabaseServicesTest"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.minres.scviewer.database.test"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.minres.scviewer.database.test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>