
com.alterioncorp.perfjdbc.io.PerfOutputStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of perf-jdbc Show documentation
Show all versions of perf-jdbc Show documentation
Wrapper JDBC driver that monitors time spent inside JDBC code by thread.
JDBC driver URL:
jdbc:alterion:perf://class=<TARGET_DRIVER_CLASS>|url=<TARGET_JDBC_URL>
To get the time in millis spent inside JDBC for thread:
StopWatch.getTime()
The newest version!
package com.alterioncorp.perfjdbc.io;
import java.io.IOException;
import java.io.OutputStream;
import com.alterioncorp.perfjdbc.PerfProxy;
import com.alterioncorp.perfjdbc.StopWatch;
public class PerfOutputStream extends OutputStream implements PerfProxy {
private final OutputStream target;
public PerfOutputStream(OutputStream target) {
super();
this.target = target;
}
@Override
public void write(int b) throws IOException {
StopWatch.start();
try {
target.write(b);
}
finally {
StopWatch.stop();
}
}
@Override
public void write(byte[] b) throws IOException {
StopWatch.start();
try {
target.write(b);
}
finally {
StopWatch.stop();
}
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
StopWatch.start();
try {
target.write(b, off, len);
}
finally {
StopWatch.stop();
}
}
@Override
public void flush() throws IOException {
StopWatch.start();
try {
target.flush();
}
finally {
StopWatch.stop();
}
}
@Override
public void close() throws IOException {
StopWatch.start();
try {
target.close();
}
finally {
StopWatch.stop();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy