Comparing performance of different Java code designs - benchmarking

Here's the problem:
How do I run the java compiler (preferably Sun's javac) without getting any compile time optimization?
I'd like to be able to compile a number of different programs to java bytecode - without having any optimization done by the compiler.
The metric I want to use on the design of these programs is the "total number of bytecode instructions executed".
The designs I want to compare can be reduced to "straight-line programs" with no conditionals or loops so I can learn a lot just by looking at the bytecodes emitted the compiler.
Any pointers or help greatly appreciated.
Cheers,
Dafydd

CORBA is supported by Windows machines (Windows XP/2000 as I know of it) and other APIs may be bought or included in some enterprise applications.
RMI and CORBA are about as fast as each other. RMI-IIOP is slower then RMI and CORBA, however, it can sometimes go a little faster depending on deployment and environment.

Similar Messages

  • Performance ISSUE of JAVA Code

    Hello,
    We are having Delphi application. But as per our requirements we have to migrated the Delphi code to java. We have done this but it is consuming the 3 times more time as compare to Delphi Application.
    We have used simple primitive types and arrays. But there are some loops which runs 4-8lac (800000) times.
    Colud you please suggest me some ways to improve the performance, as it is very critical for me ?
    Thanks,
    Satbir

    We have done this but it is consuming the 3
    times more time as compare to Delphi Application.
    We have used simple primitive types and arrays. But
    there are some loops which runs 4-8lac (800000)
    times.Sometimes trying too hard will make things slower.
    I have some suggestions:
    1) Do not inline functions yourself. This will in the best case have no effect and in the worst case make your code buggy. If your code is written according to good object-oriented methods it is probably not even possible.
    2) Don't flog the garbage collector. If your inner loop creates new objects, don't release them for the collector to clean up. Instead put them in a free list and reuse them. For general coding this isn't such a great idea, because the collector can reclaim objects about as efficiently as you can recycle them yourself. But inside a tight loop it can help a lot.
    2.1) Objects with finalizers are slow to garbage collect. Avoid finalizers in performance-critical code. (You can use classes that have finalizers, you just don't want them to be garbage collected while in tight code). Some of the classes provided by the Java API have finalizers also.
    3) Try using the server VM.
    4) Try different versions of the JDK. Some people have found that 1.4 is slower than 1.3, others find it is faster. Both are much faster than 1.2.
    5) String operations in Java are very slow. Much slower even than they usually are. StringBuffers can be 4-5 times faster than Strings, but even then string handling is just not fast. See if you can minimize the amount of string handling in your tight loops.
    6) Synchronization is quite slow also. It is faster in 1.4, but it is still slow. Don't synchronize unless absolutely necessary. Some synchronized operations can be done instead with volatile variables, unfortunately many things cannot.
    7) Make sure you have enough heap space for everything to fit comfortably. If the garbage collector is running during a tight loop, this will kill your performance.
    8) Some of the calls to the Java API are very slow. Some standard API classes, such as Hashtable, have synchronized methods, which can cause hidden slowing. Other functions are just plain slow in general.
    9) Try using the -Xrunhprof option to profile your code. While it will run much more slowly with the profiler enabled, it will at least indicate where the slowness is. It might not be what you expect.

  • Should I do this with Java Code or Stored Procs ? (for best performance)

    Hi All,
    I need to decide where should I implement my business logic, in Java code or Stored procs.
    Here is the requirement :
    - One Order has 70 products (Order_Table )
    - Can be duplicate products, so I have to do summarize / grouping by product
    - For every product, I have to check, if it is entitled for a Bonus product, then I have to Insert one to Bonus_Table.
    - This is done when/after the transaction is SAVED (COMMIT)
    The question is, which one has better PERFORMANCE :
    (1) Create a rowsetIterator on the Order details (70 products) and call a stored procedure to do the logic for every single product (so that the Insert to Bonus_Table done in stored proc). means the stored proc will be called 70 times.
    OR
    (2) After the transaction is COMMITted, call the stored procs ONCE to do the logic for all the products at once.
    OR
    (3) I do all the logic with Java Code within ADF
    Given the requirement above, which approach is most efficient / best performance ?
    Thank you very much,
    xtanto

    Problem with this is that you ask 100 people and you probably get 100 different answers. ;o)
    Many would say that you push as much business logic into the database with your data; others might say you only put data in your database and your business logic is kept on the application server.
    In reality your would probably have a mix of both and your decision would probably be influenced by your own background ...
    Can't be more precise than that.
    Grant

  • How to compare 2 different repositories in Designer 2000?

    How to compare 2 different repositories in Designer 2000?
    Is it possible to compare repositories?
    If yes, how can i do that? Is there a tool for this?
    Situation:
    I've 2 different designer repositories. I've compared in the database schema DES2_MANAGER the table SDD_ELEMENTS with the second database.
    I've compared the modules, where the last_update_date was different.
    Result was 10 screens. So now i want to compare these modules(SCREEN) in designer with an other designer Repositorie.
    Thanks anyway

    If yo will click on the name/title of the document (there'll be a small arrow on the right of it), you will get this menu:
    You can choose to browse all versions....

  • Java code to perform admin tasks

    Hi All,
    I am in need to develop a java program which allows me to perform add (new account creation)/ modify/delete/suspend/change password/ search operations on the groupwise accounts.
    Is this possible through java code or it has to be done using c++.
    Any inputs towards this will be highly appreciated. Thanks in advance
    Thanks,
    Gangadhar

    Wait ! Noboby ? OK, I'll do it
    public void onBtnAction ()
        if (!fresh)
            refresh ();
    }Seriously, did you expect anyone to answer such a cryptic question ?

  • Need Java Code or Program to compare 2 XML files ???

    Hi All,
    I need Any java code snippet to compare 2 XML files? Please help me..
    Thanks,
    J.Kathir

    Can you explain which possibilities you rejected while searching for that on the Internet? That may give us some insight into your actual requirements.

  • Invoking Acrobat PDF compare from Java code

    Need to invoke the Adobe Acrobat XI's PDF compare feature using Java code.
    Description:
    ========
    We are exploring the possibilities of passing 2 PDF's from Java to Adobe Acrobat XI SDK to get the compared results in new PDF.
    If anyone has explored with this feature... please share your thoughts.

    You would need to write a custom plugin to Acrobat that calls the compare APIs (as they are only accessible from C/C++).  Your plugin can then expose whatever from of IAC/IPC that it wishes to communicate with your Java code.
    Of course, this is all DESKTOP code since Acrobat can't be used on a server.

  • Different transaction codes useful for Performance Monitoring

    Hi Experts,
    Please can you guide me on this question, as to what are the different transaction codes useful for Performance Monitoring i.e. workload statistics and database statistics? What kind of statistics do each of these codes provide?
    Many thanks,
    Mithun

    Hi Mithun
    In performance issuses you need to look in terms of many ways that is..
    Workload analsys
    ST03N: Statistics Regards Locallly
    ST03G: Statistics Regards Golbally
    STAD: Individual Statistics Regards
    STATTRAACE: Individual Statistics Regards Trace
    ST07 : User Distribution
    Buffers and Memory
    ST02 : Buffers and Memory and swaps monitoring
    ST10: Table Acess
    OS Monitoring
    OS04: Locally monitoring
    OS07: Remotely monitoring
    OS01: LAN check
    DataBase Side
    ST04: Performance overview
    DB01: Exclusive locks
    DB02: Tables/Indexes
    BackgroundJobs monitor
    SM37
    other tcodes
    ST22: Abap Dumps
    SM12: Lock Entries
    SM56: NumberRange Buffers
    SU56: User Buffer
    all above transactions are need to monitor for Performance.
    Regards
    Bandla

  • Need  java code to perform refresh button action using swings and awt

    i need java code to perform refresh button action using swings and awt.please help me

    Wait ! Noboby ? OK, I'll do it
    public void onBtnAction ()
        if (!fresh)
            refresh ();
    }Seriously, did you expect anyone to answer such a cryptic question ?

  • How to compare two huge xml files(50MB+) using Java Code

    I want to compare two huge xml files using java code and need to find the difference of those xml files
    is there any API for that

    You should find third party API

  • Why we extend JFrame in java swings? how is it different from code not ...?

    how is it different from code nt extending JFrame?
    please explain the role of contentpane in both cases?
    thanx

    Search the net for examples and/or explanations of "inheritance vs composition.
    For the role of a contentPane, read the API for interface RootPaneContainer and class JRootPane. The second named API also has a link to the Swing tutorial on How to Use Root Panes.
    db

  • Malloc()/free() performance in JNI C code 9-10x slower than C application

    I posted this as a bug report, but thought it might be worth also seeking advice here.
    I'm working on a product under Windows which is integrated using JNI to a 3rd party file format conversion C++ library which uses a lot of new/delete (malloc/free) calls. I found the performance to be dramatically slower when running under Java compared to a standalone executable.
    After many steps, I eventually wrote a small C program which simply loops over many malloc/free calls for 16 bytes, and took an average time. I found when I run this C program in a cmd.exe window, it runs about 9-10 times faster than if it is executed via JNI (Java calls the routine just once).
    I can only guess that the JVM is somehow over-riding malloc/free, but this is an extremely high performance penalty. I found under Java 6, the JNI code runs about 5x slower, which is an improvement, but still very slow.
    Does anyone know if this behaviour is expected?
    Cheers,
    David
    EXPECTED VERSUS ACTUAL BEHAVIOR :
    EXPECTED -
    I would have expected that the performance of malloc/free to be the same regardless of whether my native code is executing inside a JNI call, or as an ordinary program.
    ACTUAL -
    For Java 1.5.0_0-b03, some example timings in milliseconds (Pentium 4 1.8GHz):
    0.004461
    0.004494
    0.004498
    For Java 1.6.0-b105:
    0.002367
    0.002375
    0.002366
    When run as a process in a cmd.exe window:
    0.000487
    0.000497
    0.000489
    REPRODUCIBILITY :
    This bug can be reproduced always.
    ---------- BEGIN SOURCE ----------
    Java code is just:
    package com.nuix;
    public class Test
        private static native void doit();
        public static void main(String[] args)
            System.loadLibrary("test.dll");
            doit();
    }C code is as follows (#define JAVA when building test.dll).
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    #define COUNT 10000000
    void doit()
        DWORD t1 = GetTickCount();
        for (int i = 0; i < COUNT; i++)
            int *data = (int *)malloc(16);
            data[0] = i;
            free(data);
        DWORD t2 = GetTickCount();
        fprintf(stderr, "Malloc average time msec == %f\r\n", (double)(t2 - t1) / (double)(COUNT));
        fflush(stderr);
    #ifdef JAVA
    #include <jni.h>
    #ifdef __cplusplus
    extern "C" {
    #endif
    JNIEXPORT void JNICALL Java_com_nuix_Test_doit
      (JNIEnv *env, jclass klass)
        doit();
    #ifdef __cplusplus
    #endif
    #endif
    int main()
        doit();
    }

    The speed of which Java executes is highly dependent on what device you are running it on. For example we have noted that a number of our J2ME programs run very slowly on many Motorola implementations, however that exact same code runs increadible fast on Nokia phones.
    You can't really make a broad sweeping statment like C# is faster than Java and vice versa. All you can really say is that on this specific device with this version of the VM running this application, C# is faster. Changing any of those parameters may result in a significantly different result.
    Really it comes down to what does the device manufacturer really want to support. Nokia has put a lot of effort into their J2ME platforms. As a result, their VM implementations are getting better (and faster) with every release. Other manufacturers are not making this same kind of commitment and as a result, their handsets are less optimal for running J2ME applications.
    So I guess the short answer is. Your question cannot be answered until you identify the version of the device, and the specific version of the VM you ran your test on.
    By the way, if you ran it on an Emulator, all bets are off. Performance on the Emulator and performance are usually different and can be significantly different.
    Cheers,
    Angus

  • How to get af:commandbutton id in java code when it is triggered?

    Hi All
    In my application's homepage, I am using 2 af:commandbuttons and each using action attribute to call a method. Both are calling the same method, and based on its id, it should perform different operations. Could anyone please tell me how to get command buttons id in java code, when it is triggered.
    Regards
    Venkat

    Venkat,
    why not call different methods from each button?
    public String actionButton1()
    return doAction("button1");
    public String actionButton2()
    return doAction("button2");
    public String doAction(String aBuuton)
    if ("button1".equalsIgnoreCase(aButton))
    // do work for button 1
    return "abc";
    }else {
    // do work for button 2
    return "abc";
    }Now you user actionbutton1 for the first button and actionButton2 for the second.
    Or you directly implement two different methods in the bean and call each one directly from the button.
    Timo

  • [UCCx] Change volume of an audio file (java code)

    Hello guys,
    Thanks to the many examples I compiled on the subject, I was able to create a script that mixes 2 audio wav files into a 3rd one. Basically the goal is to mix a first audio file containing some speech with a second one containing some music, these files being encoded identically (8 bits, 8KHz, mono wav files). The resulting file must be encoded in the same format than the initial ones.
    The mixing operation is performed thanks to the MixingAudioInputStream library found online (it can be found here).
    It is not the most beautiful Java code (I am no developer), but it works:
    Document doc1 = (Document) promptFlux1;
    Document doc2 = (Document) promptFlux2;
    Document docFinal = (Document) promptFinal;
    javax.sound.sampled.AudioFormat formatAudio = null;
    java.util.List audioInputStreamList = new java.util.ArrayList();
    javax.sound.sampled.AudioInputStream ais1 = null;
    javax.sound.sampled.AudioInputStream ais2 = null;
    javax.sound.sampled.AudioInputStream aisTemp = null;
    javax.sound.sampled.AudioFileFormat formatFichierAudio = javax.sound.sampled.AudioSystem.getAudioFileFormat(new java.io.BufferedInputStream(doc1.getInputStream()));
    java.io.File fichierTemp = java.io.File.createTempFile("wav", "tmp");
    ais1 = javax.sound.sampled.AudioSystem.getAudioInputStream(doc1.getInputStream());
    formatAudio = ais1.getFormat();
    aisTemp = javax.sound.sampled.AudioSystem.getAudioInputStream(doc2.getInputStream());
    byte[] bufferTemp = new byte[(int)ais1.getFrameLength()];
    int nbOctetsLus = aisTemp.read(bufferTemp, 0, bufferTemp.length);
    java.io.ByteArrayInputStream baisTemp = new java.io.ByteArrayInputStream(bufferTemp);
    ais2 = new javax.sound.sampled.AudioInputStream(baisTemp, formatAudio, bufferTemp.length/formatAudio.getFrameSize());
    audioInputStreamList.add(ais1);
    audioInputStreamList.add(ais2);
    MixingAudioInputStream mixer = new MixingAudioInputStream(formatAudio, audioInputStreamList);
    javax.sound.sampled.AudioSystem.write(mixer, formatFichierAudio.getType(), fichierTemp);
    return fichierTemp;
    The only downside to this is that the music can be a little loud comparing to the speech. So I am now trying to use the AmplitudeAudioInputStream library to adjust the volume of the second file (it can be found here).
    Here are the additional lines I wrote to do this:
    ais2 = new javax.sound.sampled.AudioInputStream(baisTemp, formatAudio, bufferTemp.length/formatAudio.getFrameSize());
    org.tritonus.dsp.ais.AmplitudeAudioInputStream amplifiedAudioInputStream = new org.tritonus.dsp.ais.AmplitudeAudioInputStream(ais2, formatAudio);
    amplifiedAudioInputStream.setAmplitudeLinear(0.2F);
    audioInputStreamList.add(ais1);
    audioInputStreamList.add(amplifiedAudioInputStream);
    MixingAudioInputStream mixer = new MixingAudioInputStream(formatAudio, audioInputStreamList);
    javax.sound.sampled.AudioSystem.write(mixer, formatFichierAudio.getType(), fichierTemp);
    return fichierTemp;
    The problem is I always get the following exception when executing the code:
    could not write audio file: file type not supported: WAVE; nested exception is: java.lang.IllegalArgumentException: could not write audio file: file type not supported: WAVE (line 30, col:2)
    The error is on the last line (the write method), but after many hours of tests and research I cannot understand why this is not working... so I have added some "debugging" information to the code:
    System.out.println("file1 audio file format: " + formatFichierAudio.toString());
    System.out.println("file1 file format: " + ais1.getFormat().toString());
    System.out.println("file2 file format: " + ais2.getFormat().toString());
    System.out.println("AIS with modified volume file format: " + amplifiedAudioInputStream.getFormat().toString());
    System.out.println("Mixed AIS (final) file format: " + mixer.getFormat().toString());
    AudioFileFormat.Type[] typesDeFichiers = AudioSystem.getAudioFileTypes(mixer);
    for (int i = 0; i < typesDeFichiers.length ; i++) {
    System.out.println("Mixed AIS (final) #" + i + " supported file format: " + typesDeFichiers[i].toString());
    System.out.println("Is WAVE format supported by Mixed AIS (final): " + AudioSystem.isFileTypeSupported(AudioFileFormat.Type.WAVE, mixer));
    System.out.println("Destination file format: " + (AudioSystem.getAudioFileFormat((java.io.File)f)).toString());
    AudioInputStream aisFinal = AudioSystem.getAudioInputStream(f);
    System.out.println("Is WAVE format supported by destination file: " + AudioSystem.isFileTypeSupported(AudioFileFormat.Type.WAVE, aisFinal));
    try {
    // Ecriture du flux résultant dans un fichier
    javax.sound.sampled.AudioSystem.write(mixer, formatFichierAudio.getType(), fichierTemp);
    return fichierTemp;
    catch (Exception e) {
    System.err.println("Caught Exception: " + e.getMessage());
    Which gives the following result during execution:
    file1 audio file format: WAVE (.wav) file, byte length: 146964, data format: ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame, , frame length: 146906
    file1 file format: ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame,
    file2 file format: ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame,
    AIS with modified volume file format: ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame,
    Mixed AIS (final) file format: ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame,
    Mixed AIS (final) #1 supported file format: WAVE
    Mixed AIS (final) #2 supported file format: AU
    Mixed AIS (final) #3 supported file format: AIFF
    Is WAVE format supported by Mixed AIS (final): true
    Destination file format: WAVE (.wav) file, byte length: 146952, data format: ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame, , frame length: 146906
    Is WAVE format supported by destination file: true
    So everything tends to show that the format should be supported and the mixed AIS should be written to the file... but I still get the error.
    I am really confused here, if someone could help it would be great.
    Thanks in advance!
    PS: I have attached print screens of the actual script, without the "volume adjustment" code.

    Hi,
    well I started writing a similar solution but it did not work either so I just put it on hold.
    I also tried to get hold of the streaming "device" abstraction of UCCX to adjust the volume while "playing" but that was a dead end, too, unfortunately.
    Sorry about my previous comment on your StackOverflow post, that time I thought it was kind of out of context but I believe you only wanted to ask about this issue on all available forums.
    G.

  • I Need Java code for following Algorithm

    * I Need Java code for following algorithm. Kindly any one help.
    1. Read the contents (ideas and its corresponding scores) from two files named as 'a' and 'b'.
    2. Stored the file 'a' contents in array a[].
    3. Stored the file 'b' contents in array b[].
    4. compare both files like
    if(a.equals(b[j])
    Writing the common idea and add the score from file 'a' and 'b'.
    else
    write the uncommon idea and its score..
    For example :
    Form Agents.txt
    action,65
    architecture,85
    eco-,15
    essay,30
    form,85
    form,85
    link,40
    tangent,25
    Form Agents1.txt
    Black holes,69
    essay,78
    Herewith i have above mentioned two files named as Form Agents and Form Agents1.
    Form Agents has eight fields
    Form Agents1 has two fields
    --> 'essay' is common in two files, so store the idea 'essay' and add the score from Form Agents score is '30' and Form Agents1 has 78 (essay 108).
    Finally it stores idea in another file with uncommon fields also.
    Please help us.

    We have tried with following code.
    But we cant add the scores.
    For Example:
    Form Agents.txt --> has "essay,30"
    Form Agents1.txt --> has "essay,78"
    Result is: essay,108
    Finally it stores idea in another file with uncommon fields also.
    So Any one pls correct the following code.
    try
    DataOutputStream o1=new DataOutputStream(new
    FileOutputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
    World\\Project\\Material\\art\\System Agents\\Form Agents\\CandidateResponses\\Form
    Agents.txt"));
    //Reading the contents of the files
    BufferedReader br= new BufferedReader(new InputStreamReader(new
    FileInputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
    World\\Project\\Material\\art\\System Agents\\Form Agents\\Ideological\\Form
    Agents.txt")));
    BufferedReader br1= new BufferedReader(new InputStreamReader(new
    FileInputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
    World\\Project\\Material\\art\\System Agents\\Form Agents\\Related\\Form
    Agents.txt")));
    while((s=br.readLine())!=null)
    s1+=s+"\n";
    while((s2=br1.readLine())!=null)
    s3+=s2+"\n";
    int numTokens = 0;
    StringTokenizer st = new StringTokenizer(s1);
    String[] a = new String[10000];
    String[] br_n=new String[10000];
    int i=0;
    while (st.hasMoreTokens())
    s2 = st.nextToken();
    a=s2.substring(0,s2.length()-3);
    s6=s2.substring(s2.length()-2);
    br_n[i]=s6;
    i++;
    numTokens++;
    int numTokens1 = 0;
    StringTokenizer st1 = new StringTokenizer (s3);
    String[] b = new String[10000];
    String[] br1_n=new String[1000];
    int j=0;
    while (st1.hasMoreTokens())
    s4 = st1.nextToken();
    b[j]=s4.substring(0,s4.length()-3);
    s7=s4.substring(s4.length()-2);
    br1_n[j]=s7;
    j++;
    numTokens1++;
    int x=0;
    for(int m=0;m<a.length;m++)
    for(int n=0;n<b.length;n++)
    if(a[m].equalsIgnoreCase(b[n])){
    int sc=Integer.parseInt(br_n[m]);
         int sc1=Integer.parseInt(br1_n[n]);
    int score=sc+sc1;
         o.writeBytes(a[m]+","+score+"\n");
    break;
    else
    o.writeBytes(a[m]+","+br_n[m]+"\n");
    break;
    }catch(Exception e){}

Maybe you are looking for

  • How do I block pings from the outside to the ASA 5505 outside interface?

    I was asked to block pings from the internet to the outside interface of our ASA-5505 firewall.  I found a post that said to enter "icmp deny any outside", however that does not do it. I created an ACL to try and do the trick, also to no avail: acces

  • How can I read realtime data from a data socket using DIAdem

    I am currently routing data from an instrument using LabView 7.1 to a data socket. I was trying to figure out how to access that data in real time in DIAdem through the data socket. Another option would be to use the downloaded LabView/DIAdem VI pack

  • Javax.naming.NameNotFoundException

    I am using Weblogic 7.0 and while deploying an EJB during startup I get this error? Somehow, this application deployed in some developers' machines and failed on others. I have no idea why? Pls help! Wen [exec] weblogic.ejb20.UnDeploymentException: c

  • Significance of the picture

    hi experts, now its my turn to ask a very funny (seems) question... can any one tell me... what is the significance of the picture every where on oracle books and docs... that array of pillers and rising sun... plz dont laugh seeing this post... rega

  • Memory leak with multiple "nodes" in CustomNode

    The displayed GUI has the ability to update a view when u press a button. If I press this button many times the process becomes longer and finally results in " java.lang.OutOfMemoryError: Java heap space " I think the problem is created by the update