Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. array sort performance java vs .net c#

array sort performance java vs .net c#

Scheduled Pinned Locked Moved Java
csharpjavaapachevisual-studiolinq
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nipsonanomimata
    wrote on last edited by
    #1

    import java.util.Arrays;
    import org.apache.commons.lang.time.*; //
    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#

    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
    
    D T 2 Replies Last reply
    0
    • N nipsonanomimata

      import java.util.Arrays;
      import org.apache.commons.lang.time.*; //
      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#

      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
      
      D Offline
      D Offline
      David Skelly
      wrote on last edited by
      #2

      nipsonanomimata wrote:

      is this interesting?

      Not really.

      1 Reply Last reply
      0
      • N nipsonanomimata

        import java.util.Arrays;
        import org.apache.commons.lang.time.*; //
        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#

        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
        
        T Offline
        T Offline
        TorstenH
        wrote on last edited by
        #3

        how much RAM is your java-runtime allowed to access?

        regards Torsten When I'm not working

        N 1 Reply Last reply
        0
        • T TorstenH

          how much RAM is your java-runtime allowed to access?

          regards Torsten When I'm not working

          N Offline
          N Offline
          nipsonanomimata
          wrote on last edited by
          #4

          how can i check how much ram is my java-runtime allowed to access? i just installed the jdk1.7 , and build the code using netbeans 7.01

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups