Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class sum
- {
- static class X
- {
- double i, j, k;
- }
- private static final int SIZE = 1 << 24;
- static ArrayList<X> ax;
- public static void main( String args[] )
- {
- System.out.println( "press return to allocate ArrayList<X>" );
- System.console().readLine();
- ax = new ArrayList<X>( SIZE );
- for( int i = 0; i < SIZE; i ++ )
- {
- X x = new X();
- x.i = Math.random();
- x.j = Math.random();
- x.k = Math.random();
- ax.add( x );
- }
- System.out.println( "press return to make sum" );
- System.console().readLine();
- double result = 0.0;
- double t = System.nanoTime();
- for( int m = 2; m < 100; m++ )
- for( int i = 0; i < SIZE; i++ )
- {
- X x = ax.get( i );
- result += x.i * m;
- result += x.j * m;
- result += x.k * m;
- }
- t = System.nanoTime() - t;
- System.out.println( result );
- System.out.println( t / 1000000000.0 );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement