Merge branch 'master' of https://github.com/Camille31/MovieRecommender
This commit is contained in:
		@@ -0,0 +1,63 @@
 | 
			
		||||
package com.camillepradel.movierecommender.testscript;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedInputStream;
 | 
			
		||||
import java.io.DataInputStream;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.net.MalformedURLException;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
 | 
			
		||||
public class TestGetRecommendations {
 | 
			
		||||
 | 
			
		||||
	public static void main(String[] args) {
 | 
			
		||||
		
 | 
			
		||||
		String urlStart = "http://localhost:8080/MovieRecommender/recommendations?user_id=";
 | 
			
		||||
		int nbIterations = 100;
 | 
			
		||||
		int userId= 0;
 | 
			
		||||
		long startTime = System.nanoTime();
 | 
			
		||||
 | 
			
		||||
		for (int i= 0; i < nbIterations; i++) {
 | 
			
		||||
			
 | 
			
		||||
		    URL u;
 | 
			
		||||
		    InputStream is = null;
 | 
			
		||||
		    DataInputStream dis;
 | 
			
		||||
 | 
			
		||||
		    try
 | 
			
		||||
		    {
 | 
			
		||||
		      u = new URL(urlStart + userId);
 | 
			
		||||
		      is = u.openStream();
 | 
			
		||||
		      dis = new DataInputStream(new BufferedInputStream(is));
 | 
			
		||||
		      while ((dis.readLine()) != null)
 | 
			
		||||
		      {
 | 
			
		||||
		      }
 | 
			
		||||
		      System.out.println(i + "/" + nbIterations);
 | 
			
		||||
		    }
 | 
			
		||||
		    catch (MalformedURLException mue)
 | 
			
		||||
		    {
 | 
			
		||||
		      System.err.println("Ouch - a MalformedURLException happened.");
 | 
			
		||||
		      mue.printStackTrace();
 | 
			
		||||
		      System.exit(2);
 | 
			
		||||
		    }
 | 
			
		||||
		    catch (IOException ioe)
 | 
			
		||||
		    {
 | 
			
		||||
		      System.err.println("Oops- an IOException happened.");
 | 
			
		||||
		      ioe.printStackTrace();
 | 
			
		||||
		      System.exit(3);
 | 
			
		||||
		    }
 | 
			
		||||
		    finally
 | 
			
		||||
		    {
 | 
			
		||||
		      try
 | 
			
		||||
		      {
 | 
			
		||||
		        is.close();
 | 
			
		||||
		      }
 | 
			
		||||
		      catch (IOException ioe)
 | 
			
		||||
		      {
 | 
			
		||||
		      }
 | 
			
		||||
		    }
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		long endTime = System.nanoTime();
 | 
			
		||||
		System.out.println("Time to get " + nbIterations + " times recommendation page: " + (endTime - startTime) + "ns");
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user