Timing array loop performance : Array « Collections Data Structure « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Collections Data Structure » ArrayScreenshots 
Timing array loop performance
   
public class TimeArray {
  public static void main(String args[]) {
    long startTime = System.currentTimeMillis();
    for (int i = 0, n = Integer.MAX_VALUE; i < n; i++) {
      ;
    }
    long midTime = System.currentTimeMillis();
    for (int i = Integer.MAX_VALUE - 1; i >= 0;) {
      ;
    }
    long endTime = System.currentTimeMillis();
    System.out.println("Increasing: " (midTime - startTime));
    System.out.println("Decreasing: " (endTime - midTime));
  }
}

           
         
    
    
  
Related examples in the same category
1. Initialize a static array
2. Initialization and re-assignment of arraysInitialization and re-assignment of arrays
3. Doubling the size of an arrayDoubling the size of an array
4. Array 2DArray 2D
5. Can you change the .length of an array
6. Show Two-Dimensional Array of Objects
7. ArrayListDemo done over using an ArrayList
8. Array Hunt game
9. Multi Dimension Array
10. Clone Array
11. Associates keys with valuesAssociates keys with values
12. Arrays of primitives
13. Creating arrays with new
14. Array initialization
15. Creating an array of nonprimitive objects
16. Create multidimension arraysCreate multidimension arrays
17. Initializing Array ValuesInitializing Array Values
18. Creating a Two-Dimensional Array
19. Initializing a Two Dimensional ArrayInitializing a Two Dimensional Array
20. Using the length VariableUsing the length Variable
21. Triangular array
22. Grow arrayGrow array
23. Define array for class Define array for class
24. String array and output to consoleString array and output to console
25. Multiply two matrices
26. Array Of Arrays Demo 2Array Of Arrays Demo 2
27. Array Copy DemoArray Copy Demo
28. Copying Elements from One Array to Another
29. Java program to demonstrate multidimensional arraysJava program to demonstrate multidimensional arrays
30. Extend the size of an array
31. Copy an array
32. Initialize multidimensional array
33. Get array upperbound
34. To get the number of dimensions
35. Resize an array, System.arraycopy()
36. Dump array content: Convert the array to a List and then convert to String
37. java.utils.Arrays provides ways to dump the content of an array.
38. Dump multi-dimensional arrays
39. Use the new shorthand notation to iterate through an array
40. Create a repeated sequence of character
41. Reverse array elements order
42. Convert array of primitives into array of objects
43. Array Initializers
44. Reinitializes a byte array
45. Reinitializes an int array
46. Sum all elements in the array
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.