Click here to Skip to main content
16,004,778 members
Home / Discussions / Java
   

Java

 
GeneralRe: image procesing in java Pin
Nagy Vilmos5-Dec-11 1:58
professionalNagy Vilmos5-Dec-11 1:58 
GeneralRe: image procesing in java Pin
Richard MacCutchan5-Dec-11 2:21
mveRichard MacCutchan5-Dec-11 2:21 
GeneralRe: image procesing in java Pin
bharath S h14-Dec-11 15:25
bharath S h14-Dec-11 15:25 
GeneralRe: image procesing in java Pin
Richard MacCutchan14-Dec-11 22:07
mveRichard MacCutchan14-Dec-11 22:07 
QuestionRe: image procesing in java Pin
bharath S h14-Dec-11 15:27
bharath S h14-Dec-11 15:27 
GeneralRe: image procesing in java Pin
RaviRanjanKr3-Dec-11 10:17
professionalRaviRanjanKr3-Dec-11 10:17 
GeneralRe: image procesing in java Pin
bharath S h1-Mar-12 17:37
bharath S h1-Mar-12 17:37 
Questionarray sort performance java vs .net c# Pin
nipsonanomimata29-Nov-11 3:12
nipsonanomimata29-Nov-11 3:12 
Java
import java.util.Arrays;
import org.apache.commons.lang.time.*; //<http://www.java2s.com/Code/JarDownload/commons-lang-2.4.jar.zip"

public class JavaApplication1 {
      public static void main(String[] args) {
        	java.util.Random r = new java.util.Random();
		int[] stuff = new int[100000];
		
		System.out.println("Unordered array....:");
		for (int i = 0; i < stuff.length; i++)
		{
			stuff[i] = r.nextInt(100000);
		}

                System.out.print(Arrays.toString(stuff));
                
		StopWatch watch = new StopWatch();
                        
		watch.start();
                Arrays.sort(stuff, 0, 100000);
	        watch.stop();
			
		System.out.println("Ordered array....:");
		
                System.out.print(Arrays.toString(stuff));
			
                System.out.println();
                        
		System.out.println("executed in "+watch.getTime()+" miliseconds...");
      } 		
}
//execution time of Arrays.sort in 40 miliseconds
//cpu intel i7-920 2.6 @3.2 
//os windows 7 sp1 64bit
//jdk 1.7

StopWatch api download

runs 4 times slower than the .net c# code!
what am i missing? what can i do to improve performance? is this interesting? I am familiar with c# but i wand to deep dive in java
to broaden my knowledge on languages and frameworks

here is the code in c#
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            Random r = new Random();
		    int[] stuff = new int[100000];
		    //int[] stuff = new int[] {4, 7, 2, 0, 9, 1, 6, 7, 5, 4, 3, 8, 6};
		    System.Console.WriteLine("Unordered array....:");
		    for (int i = 0; i < stuff.Length; i++)
		    {
			    stuff[i] = r.Next(100000);
			    System.Console.Write(stuff[i].ToString() + "  ");
		    }

			
			Stopwatch watch = new Stopwatch();
			watch.Start();
			Array.Sort(stuff);
			watch.Stop();
			
			System.Console.WriteLine("Ordered array....:");
			for(int k=0;k<stuff.Length;k++)
			{
				System.Console.Write(stuff[k].ToString() + "   ");
			}
			System.Console.WriteLine("executed in " + watch.ElapsedMilliseconds.ToString() + " miliseconds...");
            
            System.Console.ReadKey();
        }
    }
}
//execution time for Array.Sort() in 10 miliseconds
//cpu intel i7-920 2.6 @3.2 
//os windows 7 sp1 64bit
//.net 4.0

AnswerRe: array sort performance java vs .net c# Pin
David Skelly29-Nov-11 3:46
David Skelly29-Nov-11 3:46 
AnswerRe: array sort performance java vs .net c# Pin
TorstenH.30-Nov-11 0:49
TorstenH.30-Nov-11 0:49 
GeneralRe: array sort performance java vs .net c# Pin
nipsonanomimata30-Nov-11 1:03
nipsonanomimata30-Nov-11 1:03 
QuestionJTable cell not going away! SOLVED Pin
venomation26-Nov-11 16:34
venomation26-Nov-11 16:34 
AnswerRe: JTable cell not going away! SOLVED Pin
TorstenH.27-Nov-11 22:33
TorstenH.27-Nov-11 22:33 
Questionhelp.... Pin
djamelm6126-Nov-11 1:50
djamelm6126-Nov-11 1:50 
AnswerRe: help.... Pin
Richard MacCutchan26-Nov-11 2:39
mveRichard MacCutchan26-Nov-11 2:39 
GeneralRe: help.... Pin
mirzabeigi8-Dec-11 7:42
mirzabeigi8-Dec-11 7:42 
AnswerRe: help.... Pin
RaviRanjanKr26-Nov-11 3:40
professionalRaviRanjanKr26-Nov-11 3:40 
AnswerRe: help.... Pin
SilimSayo28-Nov-11 6:06
SilimSayo28-Nov-11 6:06 
SuggestionRe: help.... Pin
RaviRanjanKr3-Dec-11 10:21
professionalRaviRanjanKr3-Dec-11 10:21 
AnswerRe: help.... Pin
Aniket S Kulkarni28-Nov-11 20:11
Aniket S Kulkarni28-Nov-11 20:11 
GeneralRe: help.... Pin
RaviRanjanKr3-Dec-11 10:28
professionalRaviRanjanKr3-Dec-11 10:28 
GeneralRe: help.... Pin
SilimSayo19-Dec-11 15:44
SilimSayo19-Dec-11 15:44 
AnswerRe: help.... Pin
TorstenH.29-Nov-11 0:00
TorstenH.29-Nov-11 0:00 
GeneralRe: help.... Pin
Richard MacCutchan29-Nov-11 0:47
mveRichard MacCutchan29-Nov-11 0:47 
GeneralRe: help.... Pin
TorstenH.29-Nov-11 19:38
TorstenH.29-Nov-11 19:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.