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

com.alterioncorp.perfjdbc.io.PerfReader 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.Reader;
import java.nio.CharBuffer;

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

public class PerfReader extends Reader implements PerfProxy {
	
	private final Reader target;

	public PerfReader(Reader target) {
		super();
		this.target = target;
	}

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

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

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

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

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

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

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

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

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

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

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy