Skip to content

Commit

Permalink
processing
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonwatson committed Jul 31, 2024
1 parent e38c86f commit b6c4d86
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 277 deletions.
Empty file modified gradlew
100644 → 100755
Empty file.
Empty file modified lib/build.gradle
100644 → 100755
Empty file.
34 changes: 17 additions & 17 deletions lib/src/main/java/org/frc5572/util/profiler/ProfileLoggingFormat.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package org.frc5572.util.profiler;

import java.io.OutputStream;

import org.frc5572.util.profiler.LoggingProfiler.LocatedInfo;

public interface ProfileLoggingFormat {

public int compare(String leftName, LocatedInfo leftInfo, String rightName, LocatedInfo rightInfo);

public void write(String name, LocatedInfo info, double timeDivisor, OutputStream outStream);

public void begin(OutputStream outputStream);

public void end(OutputStream outputStream);

}
package org.frc5572.util.profiler;

import java.io.OutputStream;

import org.frc5572.util.profiler.LoggingProfiler.LocatedInfo;

public interface ProfileLoggingFormat {

public int compare(String leftName, LocatedInfo leftInfo, String rightName, LocatedInfo rightInfo);

public void write(String name, LocatedInfo info, double timeDivisor, OutputStream outStream);

public void begin(OutputStream outputStream);

public void end(OutputStream outputStream);

}
96 changes: 48 additions & 48 deletions lib/src/main/java/org/frc5572/util/profiler/TextProfileLoggingFormat.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
package org.frc5572.util.profiler;

import java.io.IOException;
import java.io.OutputStream;

import org.frc5572.util.profiler.LoggingProfiler.LocatedInfo;

public class TextProfileLoggingFormat implements ProfileLoggingFormat {

private TextProfileLoggingFormat() {}

public static final TextProfileLoggingFormat INSTANCE = new TextProfileLoggingFormat();

@Override
public int compare(String leftName, LocatedInfo leftInfo, String rightName, LocatedInfo rightInfo) {
return -Long.compare(leftInfo.totalTime, rightInfo.totalTime);
}

@Override
public void write(String name, LocatedInfo info, double timeDivisor, OutputStream outStream) {
try {
outStream.write((name + "\n").getBytes());
outStream.write((" visitCount: " + info.getVisitCount() + "\n").getBytes());
outStream.write((" totalTime: " + info.getTotalTime() / timeDivisor + "\n").getBytes());
outStream.write((" maxTime: " + info.getMaxTime() / timeDivisor + "\n").getBytes());
outStream.write((" minTime: " + info.minTime / timeDivisor + "\n").getBytes());
outStream.write((" avgTime: " + info.getTotalTime() / info.getVisitCount() / timeDivisor + "\n").getBytes());
} catch(IOException e) {
throw new RuntimeException(e);
}
}

@Override
public void begin(OutputStream outputStream) {
try {
outputStream.write(("Performance Log\n" + //
"================================================================================\n").getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}

@Override
public void end(OutputStream outputStream) {

}

}
package org.frc5572.util.profiler;

import java.io.IOException;
import java.io.OutputStream;

import org.frc5572.util.profiler.LoggingProfiler.LocatedInfo;

public class TextProfileLoggingFormat implements ProfileLoggingFormat {

private TextProfileLoggingFormat() {}

public static final TextProfileLoggingFormat INSTANCE = new TextProfileLoggingFormat();

@Override
public int compare(String leftName, LocatedInfo leftInfo, String rightName, LocatedInfo rightInfo) {
return -Long.compare(leftInfo.totalTime, rightInfo.totalTime);
}

@Override
public void write(String name, LocatedInfo info, double timeDivisor, OutputStream outStream) {
try {
outStream.write((name + "\n").getBytes());
outStream.write((" visitCount: " + info.getVisitCount() + "\n").getBytes());
outStream.write((" totalTime: " + info.getTotalTime() / timeDivisor + "\n").getBytes());
outStream.write((" maxTime: " + info.getMaxTime() / timeDivisor + "\n").getBytes());
outStream.write((" minTime: " + info.minTime / timeDivisor + "\n").getBytes());
outStream.write((" avgTime: " + info.getTotalTime() / info.getVisitCount() / timeDivisor + "\n").getBytes());
} catch(IOException e) {
throw new RuntimeException(e);
}
}

@Override
public void begin(OutputStream outputStream) {
try {
outputStream.write(("Performance Log\n" + //
"================================================================================\n").getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}

@Override
public void end(OutputStream outputStream) {

}

}
Loading

0 comments on commit b6c4d86

Please sign in to comment.