Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instrumentation to count the number of 8/16-bit conversions performed. #4

Open
wants to merge 1 commit into
base: ping/hybrid-buffer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/heronarts/lx/LXEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public class LXEngine extends LXComponent implements LXOscComponent, LXModulatio
public final DiscreteParameter focusedChannel = new DiscreteParameter("Channel", 1);

public final BoundedParameter framesPerSecond = new BoundedParameter("FPS", 60, 0, 300);
public int conversionsPerFrame = 0;

LXBlend[] channelBlends;
private final AddBlend addBlend;
Expand Down Expand Up @@ -966,6 +967,7 @@ protected void enableAutoTransition(int autoTransitionThreshold) {

public void run() {
this.hasStarted = true;
int initialConversionCount = PolyBuffer.getConversionCount();

long runStart = System.nanoTime();

Expand Down Expand Up @@ -1258,6 +1260,7 @@ public void run() {
this.logTimers = false;
}

conversionsPerFrame = PolyBuffer.getConversionCount() - initialConversionCount;
}

public class NetworkThread extends Thread {
Expand Down
14 changes: 9 additions & 5 deletions src/heronarts/lx/PolyBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/
public class PolyBuffer {
public enum Space {RGB8, RGB16};

private LX lx = null;
private Map<Space, Buffer> buffers = new EnumMap<>(Space.class);
private Set<Space> freshSpaces = EnumSet.noneOf(Space.class);
private static int conversionCount = 0;

public PolyBuffer(LX lx) {
this.lx = lx;
Expand Down Expand Up @@ -70,21 +70,25 @@ protected void updateBuffer(Space space) {
switch (space) {
case RGB8:
if (isFresh(Space.RGB16)) {
LXColor16.longsToInts((long[]) getArray(Space.RGB16),
(int[]) buffer.getArray());
LXColor16.longsToInts((long[]) getArray(Space.RGB16), (int[]) buffer.getArray());
conversionCount++;
}
break;
case RGB16:
if (isFresh(Space.RGB8)) {
LXColor.intsToLongs((int[]) getArray(Space.RGB8),
(long[]) buffer.getArray());
LXColor.intsToLongs((int[]) getArray(Space.RGB8), (long[]) buffer.getArray());
conversionCount++;
}
break;
}
freshSpaces.add(space);
}
}

public static int getConversionCount() {
return conversionCount;
}

// The methods below provide support for old-style use of the PolyBuffer
// as if it were only an RGB8 buffer.

Expand Down