/* * Copyright (C) 2009 E.Albert, P.Arenas, S.Genaim, G.Puebla, and D.Zanardini * https://costa.ls.fi.upm.es * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package complexityClasses; /** * This class allows executes the methods in the different complexity * classes. This can be used for comparing how the runtime increases * with the value of entry. * * @author German Puebla * */ public class Tester { public static void main (String[] a) { final int entry = 41; double d0; int res; Constant c = new Constant(); d0 = System.currentTimeMillis(); res = c.funConstant(entry); printResults("Constant", res, d0); Logarithmic log = new Logarithmic(); d0 = System.currentTimeMillis(); res = log.funLogarithmic(entry); printResults("Logarithmic", res, d0); Linear lin = new Linear(); d0 = System.currentTimeMillis(); res = lin.funLinear(entry); printResults("Linear", res, d0); NLogN nln = new NLogN(); d0 = System.currentTimeMillis(); res = nln.funNLogN(entry); printResults("NLogN", res, d0); Quadratic q = new Quadratic(); d0 = System.currentTimeMillis(); res = q.funQuadratic(entry); printResults("Quadratic", res, d0); Exponential exp = new Exponential(); d0 = System.currentTimeMillis(); res = exp.funExponential(entry); printResults("Exponential", res, d0); } private static void printResults(String name, int res, double d0) { double d1 = System.currentTimeMillis(); System.out.print("For " + name + " the result is "); System.out.println(res); System.out.println("Executed in "+ (d1-d0) + " milliseconds"); } }