Slow Program depending on Sourcecode position???

Hi all,
while testing with Generics I get a litle Problem.
Here is my test Class:
public class GenericTest {
  private String s = "x";
  private long z = 500000000;
  public static void main(String[] args) {
    new GenericTest();
  public GenericTest() {
    test();
  public void test() {
     * Block non Generic
      System.out.println("Start non Generic");
      long t = System.currentTimeMillis();
      String ls = null;
      StringBox sb = new StringBox();
      for (int i = 0; i < z; i++) {
        sb.setValue(s);
        ls = sb.getValue();
      System.out.println("non Generic " + (System.currentTimeMillis() - t));
     * Block Generic
      System.out.println("Start Generic");
      long t = System.currentTimeMillis();
      String ls = null;
      Box<String> sb = new Box<String>();
      for (int i = 0; i < z; i++) {
        sb.setValue(s);
        ls = sb.getValue();
      System.out.println("Generic " + (System.currentTimeMillis() - t));
  class Box<T> {
    private T value;
    public T getValue() {
      return value;
    public void setValue(T value) {
      this.value = value;
  class StringBox {
    private String value;
    public String getValue() {
      return value;
    public void setValue(String value) {
      this.value = value;
}As you can see there are two Blocks, each one using a Class. On with a generic Desing, the other one with a concrete Type.
Both do the same.
The strange thing about it is,      regardless of which one is first in the Sourcecode, runs about 4 times faster then the second!
If the Program runs like posted, the non-Generic-Block needs about 3 sec., and the Generic-Block about 11sec.
If you change the order of the Blocks, the non-Generic-Block needs about 10 sec., and the Generic-Block about 3.5 sec.
When you put the Blocks in separate Methods they are both running fast.
Can someone please explain this to me?
Thx.
Alex
PS. Tested on Pentium 2.8Ghz and 3.2 GHz, Windows, Java 1.5.06 and 1.5.09.

Skimming over the source code, the garbage collector was also my first guess. It would surprise me if JIT optimization is responsible for the observed behaviour (e.g., why is the second block slower than the first one?). It's 4x difference (about 7 seconds!).
But when looking more closely, I noticed that there is actually neither object creation nor does any object become unreachable inside the loop ("dereferencing" usually has a different meaning, http://en.wikipedia.org/wiki/Dereference) -- it's always the same two instances: String s and the respective Box sb. Well, there is some implicit object creation of StringBuffer during println, but that's outside of the loop... Maybe you can vary the loop count or put like two more loops in each method and see what happens; I have no experience with analyzing GC-related stuff, though...
And as stated above, generics belong to the Java language, not the bytecode language that is executed by the JVM. When you look at the generated bytecode (with javap -c or jclasslib), you can see that a CHECKCAST Ljava/lang/String; bytecode instruction is inserted after the invocation of Box<String>.getValue(), while StringBox.getValue() already returns an object of type String (saving the cast). That is, in bytecode, your Box<String>.getValue() is declared like: Object getValue(). The generics information is included in the .class file, but is only relevant at compile time.

Similar Messages

  • Slow program response, crashes when creating titles and dynamic link issues

    Dear reader,
    I am now trialling Adobe CC OSX with Premiere Pro and After Effects before deciding to subscribe but I am experiencing a lot of issues while working.
    I am now working on an animation, but editing raw mxf files also gives crashes and slow responses/ program refreshes.
    1) Slow mouse response
    2) Slow program refresh while key framing visuals
    3) Rendering in PP is extremely slow when AE is open in the background, when closing AE and re-initiate the render in PP it renders super fast
    4) Crashes. When I overlay titles in my time line PP regularly crashes
    5) Dynamic Link issues when working combined in AE and PP where file connections in the time line get lost when the AE project has too many sequences
    I am curious to find out if other people are also experiencing these issues.
    I am indecisive in getting the paid yearly plan or move to FCPX instead? Or should I get a new MacPro and is this model too old?
    It worked fine 2 months ago, however I was still working on FCP7. After updating it is really bad working with it...
    My system consist of:
    MacPro mid-2010
    OSX 10.9.5 (13F34) (new installation)
    2x2,66Ghz 6-core Intel Xeon
    24GB DDR3 ECC
    Nvidia Quadro K5000, 4GB
    2x PCIe SSD 1TB
    2x HDD 3TB
    2x HDD 2TB
    Feedback is much appreciated! Best regards, Alexander

    this does work for basic colour correction but not when trying to grade an entire suqence to achieve a specific style, applying a vingette or certain effects have to be done in after effects.
    I want to try and get my whole sequence into after effects but preserve the edits and effects added in permier pro, is there any way to do this?
    rich

  • Slow programs

    Hello,
    I am writing a Java program which is running very slow. As I am adding more code to the program it gets even more slower.
    I am running it on NetBeans IDE. The configuration of my system is not a problem, it's just bad coding and I want to improve it. Is there any method by which I can monitor my code. In this way I will have an idea where the program is taking more time.
    Please suggest me something. If there are any references on the web that I can look at, then please give me the link.
    Thanks in advance.

    I observed that my program is building huge arrays of sentences and I am having problem with searching withing these arrays. This leads me to use more and more 'for' and 'while' loops:
    One example is this
    for(arrayElement = 0; arrayElement < newsArray.length; arrayElement++){
                        String stringtoExamine = newsArray[arrayElement].trim();
                        boundary.setText(stringtoExamine);
                        tempBoundary.setText(stringtoExamine);
                        int start = boundary.first();
                        for (int endOfSent = boundary.next(), endOfTempBoundary = tempBoundary.next();
                                endOfSent != BreakIterator.DONE; start = endOfSent, endOfSent = boundary.next()){
                            String fSent = stringtoExamine.substring(start, endOfSent);
                            if(!(arrayElement+1 > newsArray.length))
                                for(a=arrayElement + 1; a < newsArray.length; a++){
                                    String nxtSent = newsArray[a].trim();
                                    nxtSentB.setText(nxtSent);
                                    int nxtSentStart = nxtSentB.first();
                                    for(int endOfNxtSent = nxtSentB.next(); endOfNxtSent != BreakIterator.DONE;
                                                                    nxtSentStart = endOfNxtSent,endOfNxtSent = nxtSentB.next()){
                                            String nSent = nxtSent.substring(nxtSentStart, endOfNxtSent).trim();
    //                                        System.out.println("Sentence No.["+arrayElement+"]:"+fSent);
    //                                        System.out.println("Sentence No.["+a+"]:"+nSent);
                                            tagSentences(fSent, nSent,arrayElement,a);
                        }The above code will compare each element with every other element.
    this is working fine but it is too slow.
    Does anyone knwo a better way to implement it. Please suggest me something. And ask if I am not clear.
    Thanks

  • How to make sub programs dependent on the parent program for ESS job in Fusion Applications.

    Hi Experts,
    We have a requirment to define the ESS jobs dependent on the parent program.
    Example:
    ESS_JOB_PARENT   -- Main ESS jobs which will trigger below mentioned jobs using "ess_runtime.submit_subrequest" through PL/SQL Package.
    ESS_JOB1                 -- Parent program has to wait will ESS_JOB1 is completed. If ESS_JOB1 is errored then parent program should also be errored.
    ESS_JOB2                 -- If ESS_JOB1 is successfull then Parent program should trigger ESS_JOB2 and it has to wait till ESS_JOB2 is completed. If ESS_JOB2 is error parent program should be errored.
    ESS_JOB3                 -- If ESS_JOB2 is completed successfully then parent program should trigger ESS_JOB3 and it has to wait till ESS_JOB3 is completed. If ESS_JOB3 is error then parent program should be errored.
    Any reference (document or sample code) are highly appericiated.
    Thanks,
    Praveen

    Is there a reason why "Job Set Steps" cannot be used, that is is there a reason you need to do this programmatically ?
    Jani Rautiainen
    Fusion Applications Developer Relations
    https://blogs.oracle.com/fadevrel/

  • Running a slow program

    Hello everybody.
    I am running a software made on java language.
    Now the execution is slower than yesterday.
    I would like to know if can setup Leopard in order to run quicker my program.
    I have a mac pro early 2009, enough free memory 4.5 GB and hard disk space.
    Thanks for your help.

    Free up your disk space. Your hard disk should not go under 15% free. This arbitrary number has been found to be the break even point where the system starts to slow down*:
    http://www.macmaps.com/diskfull.html
    You have enough room for 4 hard disks on your Mac.
    - * Links to my pages may give me compensation.

  • Program a 3 axis position movement

    I have a motion controller from Nationa Aperture Inc., Model MC-CQ-4X, which controls the position movement of X-Y-Z axis. First I'm not sure if I need a driver from this manufacture, if I do , I have not located one from the list. I have very little experience with labview and need a startup process in the block diagram. There are 3 comm ports for each axis.  So, how do I setup the labview program to control movement of each axis. Please send an example setup program showing the block diagram setup.

    Hi MR2SAILOR,
    Thanks for the additional information.  It sounds like you'll need to treat this more like an instrument driver issue than a motion control issue.  I searched on our Instrument Driver Network (ni.com/idnet) and I didn't find anything from that manufacturer.  Have you tried contacting National Aperture to see if they have an instrument driver available?  I looked around a bit on their website and it seems like they intend for people to use their products with LabVIEW. 
    To clarify, do you have NI-VISA installed?
    Michael B.
    Applications Engineer

  • App-V 5.0 memory leak problem & slow program launch

    App-V 5 clients with most recent updates have a memory leak problem. Windows 7 64bit workstations with 8GB of memory will be useless within couple of days because memory has run out. Terminating App-V client process will free the memory, but system starts
    to consume it again after that. All hotfixes (up to 5) have been installed.
    Another problem is that launching some large (locally cached) programs, for example SolidWorks, takes many minutes for a program to start. With 4.6 there wasn't any performance issues.
    Any suggestions?

    I saw the exact same issue with slow load times and 50% utilization by AppVClient.exe during that time.
    AppV 5 first launch application performance
    AppV 5 - Measuring RegistryStaging load times
    The issue, specifically, is the amount of time the application takes to stage the registry is what causes the slow load and 50% CPU utilization.  I've written a script that stages the registry on your behalf that we use on server startup, after all
    the packages are loaded.
    Original Thread on MS forums:
    https://social.technet.microsoft.com/Forums/en-US/44944302-d8f3-4df1-b104-9c63345f88e0/poor-first-launch-performance-with-appv-5?forum=mdopappv

  • Slow program start

    I just got a new pc and according to specs it should be faster than my old. But when I start different programs they all take much longer time to load. I am sure it is not a virus issue, as it is a new pc and has been like that from day one. 
    A few times it has happened, that the programs load very fast. Yesterday I run a bencmark test to check the speed, and the measure was fine and according the the specs.
    But very strange was, that the rest of that day after running the bencmark, all the programs loaded suddenly very fast. Next day the pc was back in the slow mood. I have tried to disable the virus program but it does not make a difference, and according to the joblist there should be plenty of free ressources. So what what can be the reason?

    Hello again wagnerh,
    It is good to hear back from you!
    Considering the process you have identified (TiWorker.exe) has been known to cause slow performance, I recommend following the steps in this resource on Windows 8, 8.1 High Disk Usage Caused by Tiworker.exe [Fix]. This should help imrpove the functionality of your operating system. Additionally, I also recommend taking a look at this document on TiWorker.
    Please re-post with the results of your troubleshooting, and I look forward to your reply!
    Regards
    MechPilot
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the right to say “Thanks” for helping!

  • Slow program load

    I have just installed iTunes Rel 10 for a 64 bit windows 7 computer.  It takes a very log time to load the program.  Is anyone else having this problem?

    Ridiculously slow... and I am a long time user. But after a hard disc failure upon loading the latest version I sit and wait and wait and wait and wait. Wha....?

  • "Enable Access for Assistive Devices" is missing from Yosemite and my QuicKeys program depends on this to work.  Help!

    This is my second day trying to get my QuicKeys application to work in Yosemite, but "Enable Access for Assistive Devices," which QuicKeys needs to work, is missing from Yosemite.  I have gone through the entire System Preferences panel (Security and Privacy, Accessibility, Keyboard, etc.) without success - it's just not there.  I have checked this app in the Privacy pane and dragged
    "QuicKeysUserEventHelper" out of the QuicKeys Resources folder into the Applications folder so it could "appear" in the Privacy pane, and then checked it there. Is there any way to enable access for assistive devices - a Terminal command, perhaps?
    QuicKeys is my most used program, which I have had since its inception at least 10 years ago!  Help!

    Thank you for your reply!  I did everything that Startly recommended (actually, gb2), and when I dragged the QuicKeys Helper into the Privacy box. I didn't see it, but after I quit and restarted QuicKeys, it worked!  However,I had  first  dragged the QuicKeys app to the trash, emptied it, then restarted.  Next, I redownloaded QuicKeys from Startly and THEN I went to gb2's directions.  All together, my QuicKeys now works on my MacBook Air.  BUT NOW, I keep getting the warning that says that this version and activation code are already in use by another user!  I am also getting those warnings on my Mac Pro -  which had the same problem yesterday (QuicKeys not working), until I heard back from a Technical Advisor from Startly, who told me about trashing the app and redownloading from their site.  Last night, that version of QuicKeys worked WITHOUT my having to drag the QuicKeys Helper app into the Privacy pane.  Perhaps it is there, but invisible - the helper app is not visible on either of my computers' Privacy panes.
    OK, NOW WHAT DO I DO?  Every 20 seconds or so, I'm getting those annoying warning signs (on BOTH computers) and requests to put in my activation key, and then told that it is being used by another user!!!
    AM I EVER GOING TO BE ABLE TO USE MY 2 LICENSES FOR MY 2 QUICKEYS PROGRAMS???

  • Which (Live! 5.1) programs depend upon (any) DISC DETECTOR files to be present? (Windows 2000 Pr

    Having determined there is no FRIENDLY way to uninstall Disc Detector, I need to confirm how to do so MANUALLY . . . in such a manner that I don't compromise the DLL's necessary to run my other Sound Blaster Li've! 5. programs. Here is my system:
    SOUND BLASTER LIVE! 5.
    WINDOWS 2000 PROFESSIONAL
    FULLY PATCHED as of 2005/07/27
    I do realize I can disable the service in
    Administrati've Tools \ Component Services \ Console Root \ Services \ Creative Service for CDROM Access
    but I would like to know what my options are to remove it (and all of its files) permanently from my computer so that it doesn't even show up as a Service.
    Would any of the other Li've! programs stop working -or- not work properly if I
    . Hacked the Registry Key, as described here
    http://groups-beta.google.com/group/creative.products.sound_blaster.li've/msg/b266258e2eea006
    2. Manually removed all of DISC DETECTOR's files
    and if I could do so SAFELY
    3. What are the exact FILES & FOLDERS I should globally search for on my W2K system to delete?
    Thanks.
    MC

    MC,
    I'm going to have to refer you back to the red announcement at the top of each board
    <These forums are primarily intended for user interaction.
    <SCRIPT language=JavaScript>
    <!--
    document.write('<A href="' + ws + '/support/forums/disclaimer.asp]');
    //-->
    </SCRIPT>
    Read more
    The link describes it in more detail, but in essence, these forums are for user interaction, ie for people to share information, help eachother, discuss products. It is not intended as a Support board, we have people working on phone and e-mail support to assist people directly, if they need an answer from someone in Creative. We don't guarantee a response from a moderator on these forums.
    To answer your question anyway though , you should normally be able to disable it through the main multimedia program, with the SBLi've that should be Playcenter. Alternati'vely, you can disable it through the Start Up list (Start> Run> type in MSCONFIG, and untick the program under Start Up). As a last option, renaming the "ctdetect.exe" file should do it aswell (but more as a last option).
    Cat

  • Slow program start-time: Win8 Yoga 13

    Hey guys,
    I've heard a few other people mention this problem but can't find a thread on it.
    A few days after I got my Yoga 13, I noticed that programs- most notably metro apps, such as the calendar, weather, etc, can take as long as 15 seconds to load up whenever I first try to launch them. Also, there will be times where a metro app will be loading for 20+ seconds and then just report an error message that it crashed.
    Has anyone else experienced this? Aside from Office 365, Chrome, and Firefox, I have not installed anything else on this computer.
    Any suggestions?
    Cheers!
    Solved!
    Go to Solution.

    I have the same Problem, but the suggested solutions did not work.
    Configuration:
    Yoga 13, i7, 256GB SSD, 8GB Ram
    Win 8 Pro (updated to Pro)
    Kaspersky
    Office 2003
    Company Notebook
    The Desktop Applications (i. e. Outlook, Chrome, Exel, Word) are starting extremly fast. It is not measureable, maybe in one or two seconds.
    The Metro apps Need at least 12 seconds, quite often up to 20 seconds. Even simple parts like camera or the clock are needing such a Long start time.
    It does not matter if the Yoga is logged into the Company Network, my private Wifi or offline. Also deactivation from Kaspersky does not make any Change.
    Everything else is working fast, except the start from the Metro apps.

  • Very slow program launch

    1.83Ghz / 512mb Mini that's about a month old.
    I have used Onyx for the Maintenance and Optimisation.
    Restart.
    Wait for everything to load.
    Get Firefox in Quicksilver
    Press Return
    24 seconds later Firefox opens and starts loading the 3 homepages.
    Everything is slow to launch. I can't see that memory can be a factor when all I'm doing above is opening a browser.
    I assume the above can be speeded up?

    I can understand the frustration, not least because I can assure you that by and large, quick and efficient is a good way to describe the normal workings of MacOS.
    I can tell you, for example, that on my 1GHz G4 powermac (that I am using at this moment) Firefox launches from the dock in 8.9 seconds. Safari in 6.5. This system is several factors slower than your Intel mini. The G4 does, however have 1.5Gb RAM, though it currently has 8 applications open also (excluding Firefox).
    I was looking on the Mozilla site for information as to whether the current version of Firefox is Intel-native of not, but there is no clear indication one way or another. O see a reference to an earlier version that IS universal binary though, so that would seem to suggest v2 is also. In any event, you can check when it's running by opening Activity Monitor, which will indicate PPC processes.
    There's no doubt that additional memory will help overall, but I would urge you to consider the other issues I mentioned in the last message - permissions, prebinding, caches etc, because these can have a major impact on system performance. I'm assuming you have some familiarity with these issues since at the outset you mentioned OnyX, a good general purpose tool that deals with exactly these matters, and to consider re-downloading the Firefox installer on the mini and then installing again.
    I don't have regular access to an Intel mini to see how it performs, though I have set a few up for users in my networks and not found them noticeably slow in any obvious way - even using Firefox which a couple of my users prefer. Thus I would not agree that such behavior as you describe is particularly normal. Not that that comments helps much!!

  • Program dependency list

    Hi everybody, happy new year
    Is there a way to get the list of objects dependencies of an program?
    I need the list of tables, structures, function modules, includes, .... that is used by an program
    In SE80, below the program name, is showed a treeview with this list, but i can't find how this list is make
    Tanks
    Darley

    Hi Darley,
    I'm afraid there is no easy solution. The SAP coding for SE80 is kind of desatrous.
    Regards.
    Clemens.

  • Using mouse for keypress slows program

    I noticed that using a mouse to press/hold the device buttons
    onscreen in the Device Central Emulator significantly slows a movie
    framerate. Using the keyboard keys to press/hold does not slow
    framerates. I can replicate this in a very simple movie with no
    animation, using only code to measure the framerate. Anyone else
    notice this?

    This is not something that is easily done in Java. Try to do it another way.

Maybe you are looking for

  • Using a Variable Prompt - In an analysis using Top N filter (URGENT)

    Hi Experts I have created a variable prompt that is setup in the following way : Prompt Name : Number_of_rows User Input : Radio Buttons Radio Button Values : *1/ 2* (Custom Values) Variable Data Type : Number Default Selection : *1* (Specific Custom

  • Including a *.js file in JSP

    Is this the correct way to do it? <script LANGUAGE="JavaScript" SRC="./includes/calendar.js"></script>

  • Version 4 RC2,open link in new tab

    I have notice with the above version that a lot of times when I right click to open a link that the new page comes up blank. Hit refresh and page comes up

  • How to send notification when too many users connected

    Hi all ! I need to send a notification from my web container when there are over 100 users connected, does anybody know how to do it without using vendor's Api but just JEE Api ? thanks Luca

  • EA3: Connections Tab is missing

    Running EA3 with bundled JDK on Windows XP Pro. I closed the Connection Tab and cannot find how to bring it back. There is not an option in the View submenu.