All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alterioncorp.perfjdbc.io.PerfInputStream Maven / Gradle / Ivy

Go to download

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.InputStream;

import com.alterioncorp.perfjdbc.PerfProxy;
import com.alterioncorp.perfjdbc.StopWatch;

public class PerfInputStream extends InputStream implements PerfProxy {

	private final InputStream target;

	public PerfInputStream(InputStream target) {
		super();
		this.target = target;
	}

	@Override
	public int read() throws IOException {
		StopWatch.start();
		try {
			return target.read();
		}
		finally {
			StopWatch.stop();
		}
	}

	@Override
	public int read(byte[] b) throws IOException {
		StopWatch.start();
		try {
			return target.read(b);
		}
		finally {
			StopWatch.stop();
		}
	}

	@Override
	public int read(byte[] b, int off, int len) throws IOException {
		StopWatch.start();
		try {
			return target.read(b, off, len);
		}
		finally {
			StopWatch.stop();
		}
	}

	@Override
	public long skip(long n) throws IOException {
		StopWatch.start();
		try {
			return target.skip(n);
		}
		finally {
			StopWatch.stop();
		}
	}

	@Override
	public int available() throws IOException {
		StopWatch.start();
		try {
			return target.available();
		}
		finally {
			StopWatch.stop();
		}
	}

	@Override
	public void close() throws IOException {
		StopWatch.start();
		try {
			target.close();
		}
		finally {
			StopWatch.stop();
		}
	}

	@Override
	public synchronized void mark(int readlimit) {
		StopWatch.start();
		try {
			target.mark(readlimit);
		}
		finally {
			StopWatch.stop();
		}
	}

	@Override
	public synchronized void reset() throws IOException {
		StopWatch.start();
		try {
			target.reset();
		}
		finally {
			StopWatch.stop();
		}
	}

	@Override
	public boolean markSupported() {
		StopWatch.start();
		try {
			return target.markSupported();
		}
		finally {
			StopWatch.stop();
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy