Sort times in java?

Hi, I've been playing around with a linear sort idea, but I have no clue how to benchmark it. I looked at minutesort, pennysort, etc, and...well...I have no clue what filestripping or anything else like that is, I just wrote some code :) Right now I'm just sorting intergers passed to it (not from a file), and I'm sorting 1 million in .6 seconds, 10 million in 6 seconds (it's linear). I haven't tweaked anything (whatever the normal forte4j is, I just typed it in), and I'm running all this on a p3 556 with 256 of pc100 ram on windows 2k pro. Is this good? One of the worst times ever? Is there a benchmark that just tests the code without all the fancy filestripping to increase bandwidth or whatever? Thanks for your comments!

There are quite a few famous linear sorts out there. Just yesterday someone pointed me towards a Radix sort, and I found a guy who on a pentium machine allowed the radix sort to work on floats, etc. His idea could very easily be carried over to a java platform to let it be platform independant. I can't vouch for the web site, but the ideas on the page seem to make sense, at least to me (URL at bottom of post). The person who just posted is right actually, "the fastest sorting algorithm based on comparisons takes n*log(n) time." Just make a sort not based upon comparisons (such as the radix sort). As for the known upper bound part, it doesn't have to be known at the begining of the sort, but at least from what I've seen, the larger upper bounds on these types of sorts result in slower performance...which is an interesting idea actually. If you know that your numbers are going to be in the billions, other sorts might be faster (unless you have billions of numbers to sort). But if your upper bound is significantly less than the number of numbers, then you get a boost of speed. The ideas there interests me...
Anyways, please be nice, I was asking an honest question about sort times. I take it from responses though that .6 seconds for a million numbers is a lot of time, I was afraid of that :( Oh well, maybe I can get some good out of it yet. I'll probably go ahead and post my code hopefully in a few days once I got it as fast and good as I can. Thanks to those that responded, and the link is below.
http://codercorner.com/RadixSortRevisited.htm
There are many web sites out there about the radix sort, apparently it's pretty old. I just looked over some web sites about it is all. I'll try and cut down on that time, but what should I be aiming for? Oh, and as for Array.sort() or whatever...to be honest, I'm just now learning java (been using C++), and I've never heard of it. Anyone know how it sorts everything? I'll try and do some research on my own, but getting answers from other people is often faster :)

Similar Messages

  • How to change system time through java program

    Hi
    I want to know, how to change system time through java program.
    give me a idia with example.
    Thanks

    There isn't any core Java API for this. Use JNI or call an external process with Runtime.exec().
    ~

  • How to get the current GMT time in java

    Hi,
    How to get the current GMT time in java
    Thanks

    System.getCurrentTimeMillis() or new Date().
    [url http://www.javaworld.com/jw-12-2000/jw-1229-dates.html]Calculating Java dates: Take the time to learn how to create and use dates
    [url http://www.javaalmanac.com/egs/java.text/FormatDate.html]Formatting a Date Using a Custom Format

  • System time for Java Stack and ABAP Stack of PI

    HI,
         We have a scenario in which we have a synchronous flow of data. In the forward flow we have used field UZEIT in an RFC Lookup to register the inbound time and in the reverse flow we have used current time function of SAP PI mapping. PI time is the local time of the server, However UZEIT is 4 hours ahead compared to PI time.
    Both the Java and the Abap stack are installed on the same server.
    Kindly let us know the reason for the difference in time on both the stacks.
    Regards,
                Milan Thaker

    Hi,
       Yes I am refering to the System->Status time in ABAP Stack. Could you please tell me where can I check the System time of JAVA stack. I got one XML file in UME which refers to some timestamp in com.sap.security.core.usermanagement but I failed to locate this field. Please let me know where can I find the Java stack time and how can that be synchronized with ABAP.
             Also, is there any time zone settting in JAVA for UTC , the way we have in ABAP
    Regards,
                  Milan Thaker

  • How to find the Latency time in java.

    How to find the Latency time in java.

    long start = System.currentTimeMillis();
    doTheWork();
    long durationInMillis = System.currentTimeMillis() - start;You might repeat doTheWork() several (100-1000 or more) times if it is fast and the granularity of your system clock is not good enough.

  • Program to Set System Time in Java

    Is there any way to set the system time through Java. If there is can you help me some information.
    Regards,
    Shivakumar Thota

    Hey Hey,
    You could run Runtime.exec() to execute a command such as VBScipt to do it.
    Other than that you may have to take a look at Java Native Interface(JNI) that will basically take control of doing anything you need.
    Also, You may want to post this in "New To Java" or some other forum other than Java Web Start. You'll get more people to help ya.
    Hope this helped,
    --Ryan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to open directory in run time using java

    Hi All
    i hava problem for open a directory in run time in java.please help me with code.

    Please elaborate what you mean by opening a directory. You can at all times access directory content via the File class.
    File myDir=new File(<pathToDir>);
    File[] directoryContent=myDir.listFiles();

  • How to avoid the run time error  "java.lang.OutOfMemoryError"

    hi
    i have written a code to read a txt file ,i used FileReader to read a file . the code is working well for small txt files. but when i tried to read a large file(greater than 2MB), a run time error called "java.lang.OutofMemoryError" appeared .
    plz suggest the methods to read txt files of large capacity(greater than 25MB) .if possible give an example.

    thanks for ur replies
    i am new to java programming .i am a student persuing B.Tech final semester .i got struck in my project while reading a large txt file(greater than 3MB) . i am now giving a part of code that i had used in my project .it working fine with the txt files less than 3MB ,but when i am treing to read a file greater than 3MB , it is displaying a run time error "java.lang.outofmemoryerror"
    i have tried using "java -Xmx" ,it is working , but is there any better option ??
    here is the part of code:
       FileReader fin;
        al=new ArrayList();
         try
              fin=new FileReader(filename);
         catch(FileNotFoundException e)
           System.out.println("File not foumn");
         return;
    while((i=fin.read())!=-1)
           al.add(new Character((char)i));
         fin.close(); 
         Object obj[]=al.toArray();plz help me
    --santosh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Set time in Java

    How can I set the system time in Java?

    hi, you can use the Runtime.getRuntime().exec(...);
    Method to use the dos command "time"

  • Implementing Joda Time in Java Netbeans

    How do i implement joda time in java netbeans. i am reporting using ireports and on run time my report is showing java util and and time for a variable say DateOfBirth for which i don want the time to be include.how do i resolve it.
    Thank yu so much

    I am not sure I understand your question as it's posted. But let me offer a reference- there's a book being written by this guy:
    http://www.netbeans.org/community/articles/interviews/yarda-tulach.html
    on designing modular APIs. He's been involved in Netbeans from the start. Writing a plugin API is non-trivial where non-trivial means, essentially, non-commoditized knowledge needed to solve what's known as a "wicked problem".
    If you're asking what I think you're asking, no one is going to be able t type an answer to you in Sun's forums, but it's a good question and the right question to ask, that's for sure.
    best of luck!

  • Retrieve OS up time using java

    How to retrieve the Operating System's up time using Java.

    avila wrote:
    Hi,
    I'm wondering if someone found a better solution than parsing a result from a OS call.
    I was trying with System.nanoTime() function which seems to return the number of nanoseconds since the computer was turned on, but the Java documentation does not say much about where the nanoTime value comes from.
    Any help?If I recall correctly, the docs say it's an offset from "some epoch," meaning a given implementation can use whatever it wants as time zero.
    As far as I know, there's still no pure Java way to do this.

  • How create bath file in run time in java

    Hi all
    i run one bath file by using process class but i create bath file in run time in java .please help me with code.

    Dynamically Writing a batch file in Java is exactly the same as writing to a simple text file.... you just give it the file extension ".bat".
    If you can't write to a simple text file yet, you should probably buy a Java book and start working through it.
    regards,
    Owen

  • Getting the current time using java.sql.Time

    I need to set the current time in a database field. I tried the following code (using my logic) to set the current time. But, I end up getting "Jan 1, 1970" in the time field in the database.
    Here is the code :
    Calendar cal = Calendar.getInstance();
    Java.sql.Time now = java.sql.Time.valueOf(
              cal.get(Calendar.HOUR_OF_DAY) + ":" +
              cal.get(Calendar.MINUTE) + ":" +
              cal.get(Calendar.SECOND));
    What should I do to get the current time in the "now" variable? Right now, it ends up in the database as "Jan 1, 1970".
    Thanx in advance.

    Can you show me the code to do SimpleDateFormat?
    Assuming that I use the following skeleton to get the
    time value from the database, can you show me the
    code for the missing link (so as to display in the
    format "hh:mm:ss") ?
    java.sql.Time timeFromDb =
    obj.getActionTime();
    // The above code gets the "time" field from
    the database into "timeFromDb"
    // Use SimpleDateFormat to display the time
    java.text.SimpleDateFormat sdf = new
    java.text.SimpleDateFormat("hh:mm:ss");
    // Now what do I do with "sdf" and
    "timeFromDb" ?
    // Print out the time value
    System.out.printf("Time is : %s\n",
    .... );Hi,
    I don't know if you want 24h clock or not. This is the pattern for 24h clock.
    "HH:mm:ss"
    You get the text string by calling sdf.format(timeFromDb)
    Kaj

  • How can I calculate the total time in java?

    Hello!
    I need to calculate the total time!
    For example I have start time:
              Format formatter1;
              Date date1 = new Date();
              formatter1 = new SimpleDateFormat("hh:mm:ss");
              String startTime = formatter1.format(date1);
              //startTime = "14:20:40";
    And I have finish time:
              Format formatter2;
              Date date2 = new Date();
              formatter2 = new SimpleDateFormat("hh:mm:ss");
              String finishTime = formatter2.format(date2);
              //finishTime = "08:30:55";
    So, after manually calculating, I get total time: "18:10:15"
    How can I calculate the total time in java? (Using formatter1 and formatter2 I suppose)
    What I need is to print "total 18:10:15"
    Thanks!

    800512 wrote:
    I did the following but, I think something is wrong here:
    I defined before: Date date1 = new Date(); Date date2 = new Date();
    And it should be exactly 5 seconds between them.
    I found delta between date1 and date2:
    Format formatter = new SimpleDateFormat("HH:mm:ss");
              long timeInMilliFromStart = date1.getTime() - date2.getTime() ;
              Date date3 = new Date(timeInMilliFromStart);
              String timeInSecFromStart = formatter.format(date3);
    and I get always
    //timeInSecFromStart = 02:00:05
    But it should be exactly 00:00:05.
    What can be a problem?Because, like I said, a Date measure an instant in time, not a duration. So when you have 5000 ms, and you turn that into a Date, that means 5 sec. after the epoch, which works out to 1/1/1970 00:00:05.000 GMT.
    As I mentioned, if you're not currently in GMT, then you have to set the TZ of the DateFormat to GMT. Right now, it's showing you the time in your TZ. If you included the date in your SimpleDateFormat, you'd see either 1/1/1970 or 12/31/1969, depending on which TZ you're in.
    Bottom line: You're trying to use these classes in a way they're not meant for, and while you can get the results you want for a limited set of inputs if you understand what these classes do and how to work with that, it's a brittle approach and comes with all kinds of caveats.

  • Can i change system time using java

    hi guys can i change system time using java iam doing one app in that i have to change the system time (my os is windowsXP) please tell me how to change the time

    What does this have to do with Swing?
    Well, there is no Java API that I'm aware of.
    However you can execute any Windows command by using the Runtime class. So you should be able to invoke the Time command.
    Search the Java Programming forum. There are plenty of examples on using the Runtime.exec(...) command.

Maybe you are looking for

  • Rest method that can support request/responce in both xml and json formats

    Hi, I want  to create rest method that can support request/responce in both xml and json formats. I am trying in bellow way, but its not working getting error. any idea on this? Code in IService.cs : [OperationContract]        [WebGet(UriTemplate = "

  • Datatarget missing in InfoPackage

    Friends, I am on BW 3.1. I am copying data from a cube1 to Cube2. I have created update rule on Cube2 from Cube1 and Update rule are active. When I go into Infosource (of Cube1) to create InfoPackage, i do not see Cube2 in Data Target tab. Am I missi

  • UI Component Error

    Hi Experts, We have enhanced a standard component. During execution we get an error saying : &NBSP; Cannot display view BP_ADDR/AccountAddressEditViewSet An exception has occurred Exception Class  CX_BSP_WD_INV_VA_ASSIGNMENT - Assigned view BP_ADDR/A

  • How do i recover a replaced file?

    I accidentally replaced an important document with another less important one with the same name.  How do i recover that document?   Please help me, I'm in a hurry!

  • BI dashboard

    Hello, Please can someone explain me an example of a dashboard created in BI for CRM reports.What were the tools used to create the dashboard.Like i understnd what does dashboard mean..could someone give an example of dashboard created.in terms of CR