Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Timer.java:
- package BenchTiming;
- public interface ITimer {
- public void start();
- public long pause();
- public long stop();
- public void resume();
- }
- class Timer {
- long elapsed;
- long stored;
- public void start(){
- stored = 0;
- elapsed = System.nanoTime();
- }
- public void resume(){
- elapsed = System.nanoTime();
- }
- public long stop(){
- elapsed = System.nanoTime() - elapsed;
- return elapsed;
- }
- public long pause(){
- elapsed = System.nanoTime() - elapsed;
- stored += elapsed;
- return stored;
- }
- }
- ======================================================================================
- ILog.java:
- package BenchLog;
- import java.util.concurrent.TimeUnit;
- public interface ILog {
- /**
- *
- * @param s
- */
- void write(String s);
- void write(long n);
- void write(Object...values);
- void write(long x, TimeUnit t);
- }
- =====================================================================================
- ConsoleLog .java:
- package BenchLog;
- public class ConsoleLog implements ILog{
- }
- =====================================================================================
- FileLog .java:
- package BenchLog;
- public class FileLog implements ILog{
- void write(String s){
- System.out.println()
- }
- }
- =====================================================================================
- Benchmark.java:
- package Benchmark;
- public interface Benchmark {
- void run();
- void run(Object param);
- void initialize(int x);
- void clean();
- }
- =====================================================================================
- TimeUnit.java
- package BenchTiming;
- enum TimeUnit{
- NS,US,MS,S;
- public static long convert(TimeUnit t){
- switch(t){
- case TimeUnit.NS: break;
- case TimeUnit.US: t = t/10^3;
- case TimeUnit.MS: t = t/10^6;
- case TimeUnit.S: t = t/10^9;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement