Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package MyASD;
  7.  
  8. import java.util.ArrayList;
  9.  
  10. /**
  11. *
  12. * @author Student
  13. */
  14. public class Main {
  15. public long testWstawLinie(int liczbaElem){
  16.  
  17. long czasStart=System.currentTimeMillis();
  18.  
  19. ArrayList<String> list= new ArrayList();
  20.  
  21. for(int i=0; i<liczbaElem; i++){
  22. list.add("Ala");
  23. }
  24.  
  25. long czasStop=System.currentTimeMillis();
  26.  
  27. return czasStop-czasStart;
  28.  
  29. }
  30.  
  31. public long testPrzegladania(int liczbaElem, int liczbaPrzegladow){
  32.  
  33. ArrayList<String> list= new ArrayList();
  34.  
  35. for(int i=0; i<liczbaElem; i++){
  36. list.add("Ala");
  37. }
  38.  
  39. long czasStart=System.currentTimeMillis();
  40. //------------------------------------------------------------------
  41.  
  42. for(int i=0; i<liczbaPrzegladow; i++){
  43. for(int j=0; j<liczbaElem; j++){
  44. String elem=list.get(i);
  45. }
  46. }
  47.  
  48. //------------------------------------------------------------------
  49. long czasStop=System.currentTimeMillis();
  50.  
  51. return czasStop-czasStart;
  52.  
  53. }
  54.  
  55. public void testUsuwania(){
  56.  
  57. }
  58.  
  59. public static void main(String [] args){
  60. Main test=new Main();
  61.  
  62. long czas=test.testWstawLinie(100000000);
  63.  
  64. System.out.println("czas wstawiania="+czas);
  65.  
  66. long czasPrzegladania=test.testPrzegladania(100000000, 5);
  67.  
  68. System.out.println("czas przegladania="+czasPrzegladania);
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement