Which is Good for Performance?

Hi,
I am bit confused about this code from performance point of view, say If I write like this :
for(int i=0;i<1000;i++)
  //declaring variables in the loop
  int j, k;
  double d;
  CustomClassObj classObj = new CustomClassObj();
}And if I declare all the variables before the loop like this
//declaring variables before the loop
int j, k;
  double d;
  CustomClassObj classObj = new CustomClassObj();
for(int i=0;i<1000;i++)
}so which is faster from performnace point of view? As I have read some white papers and books, but some says the local variables (insode loops) are better as GC will deallocate those variables after loop.
And some suggest that dont create temporary objects inside loop... :(
Please help...!
Thanks in Advance.

Java_Cup wrote:
so which is faster from performnace point of view? As I have read some white papers and books, but some says the local variables (insode loops) are better as GC will deallocate those variables after loop.If they said that, then they were worthless. GC doesn't touch local variables. And if it did, it would be slower, because you'd have one GC task per loop iteration, rather than simply one at the end.
All the local variables used in a method are allocated in one shot when the method starts, by moving the stack pointer by an amount determined at compile time, and they are all released when the method ends by moving it back by the same amount.
It also looks like you may be confusing variables with objects.
>
And some suggest that dont create temporary objects inside loop... :(Well, that depends. If you need one object across the entire life of the loop, you might get better performance by creating it before the loop starts. I wouldn't generally do that though unless I knew that creating that object was expensive relative to the rest of the work being done in the loop. I'd stick with creating it inside the loop, where it's actually used. And of course if your logic dictates a different object for each iteration, then you have to do it inside the loop anyway.
At the end of the day, these microoptimizations don't become relevant until you observe a performance problem, profile it, and confirm by measurement, changing the code, and re-profiling, that it is in fact a problem.

Similar Messages

  • Subquery vs UNION, which is better for performance?

    I want to know which in better for performance using a subquery method or a UNION?
    Any information would be helpful and appreciated!

    Hi,
    It depends on the SQL statments and each case is different from an other one. Take a look at the oracle doc: "Designing and Tuning for Performance".
    Regards,
    CB

  • What is good for performance calculation in select st. or in formual column

    Dear Friends,
    I would like to ask you regarding what is good for performance specially i'm developing reports for EBS .
    is it better to calcualte total of 5 columns in select statment directly or using formula columns to do this,
    Regards & Thanks
    Yas

    I'd focus on easily readable query, namely use formula column if otherwise the query get too long or too complicated to read/maintain. Have inherited many ugly long queries/reports and hate to maintain or fix bugs for them etc.

  • Which is better for performance Azure SQL Database or SQL Server in Azure VM?

    Hi,
    We are building an ASP.NET app that will be running on Microsoft Cloud which I think is the new name for Windows Azure. We're expecting this app to have many simultaneous users and want to make sure that we provide excellent performance to end users.
    Here are our main concerns/desires:
    Performance is paramount. Fast response times are very very important
    We want to have as little to do with platform maintenance as possible e.g. managing OS or SQL Server updates, etc.
    We are trying to use "out-of-the-box" standard features.
    With that said, which option would give us the best possible database performance: a SQL Server instance running in a VM on Azure or SQL Server Database as a fully managed service?
    Thanks, Sam

    hello,
    SQL Database using shared resources on the Microsft data centre. Microsoft balance the resource usage of SQL Database so that no one application continuously dominates any resource.You can try the 
    Premium Preview
    for Windows Azure SQL Database which offers better performance by guaranteeing a fixed amount of dedicated resources for a database.
    If you using SQL Server instance running in a VM, you control the operating system and database configuration. And the
    performance of the database depends on many factors such as the size of a virtual machine, and the configuration of the data disks.
    Reference:
    Choosing between SQL Server in Windows Azure VM & Windows Azure SQL Database
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • Use BADI or LGF script logic? Which is good in performance

    Hello,
    I have a situation wherein a choice is to be made among the "BADI" or "script logic" having DESTINATION_APP which is along with WHEN clause.
    Below is the code in which WHEN clause is used:
    Code Starts****
    XDIM_MEMBERSET CATEGORY=FC_CUR
    *DESTINATION_APP=GROSSMARGIN
    *SKIP_DIM =WEEK
    *ADD_DIM PLAN_PARTNER = PP_NA, RPTCURRENCY = LC
    *WHEN CATEGORY     
        *IS "FC_CUR"     
                  *REC(EXPRESSION=%VALUE%)
    *ENDWHEN
    *****Code Ends****
    The business requirement could be changing as we are at initial stage, wherein i may have to incorporate some data mapping logic which can also be handled through scripts instead of using BADI.
    The major concern is if BADI would be most prefferable over script logic having WHEN clause to acheive the optimal performance considering large no. of records that needs to be written to the target APPLICATION
    from the source application?
    OR
    The script with WHEN statement is fine if the data mapping is pretty simple and would not have much impact on performance compared to using of BADI even if the records to be moved is huge.

    If data mapping is simple you can opt for script logic . If requirement is complex then you can go for BADI . You can check this [How-to|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70187b3e-d5ce-2d10-d780-bb8b1a5b0bdc?QuickLink=index&overridelayout=true] 6 th page on performance considerations of BADI .
    A well designed BADI implementation is faster than script logic

  • Which Processor Good for Oracle Apps 11i

    Hello Folks,
    I am planning to buy dell laptop to install oracle Apps 11i,
    The dell laptop come with the two processor.
    1.AMD Athlon 64 X2 Dual-core Processor
    2.Intel® CoreTM 2 Duo Processor
    So pls advice me to choose the best one.
    Thanks, Raghu.K

    The real bottleneck will be disk and memory. I liked the server Opteron processors but was never a fan of the mobile ones. I have always had fantastic performance running 11i and R12 on Centrino or Core 2 duo processors. Get a machine with the latest Santa Rosa chipset, and you can install 4 GB of RAM and have it visible to the OS (at least for Linux). I just recently configured a ThinkPad T61 with OpenSuse 10.3, 4 GB of Ram, 240 GB of disk that is running Apps 11.5.10.2 with 10.2.0.3 database and Apps R12 and Demantra Demand Planning 7.1.1 in an OAS 10.1.3 J2EE and Web Server concurrently. This is also running a KVM Windows virtual machine.

  • When I print a web page, the font size is always the default (which is good for screen reading, but too big for printing), even when I use Text Zoom to make it smaller.

    How can I change the font size when printing web pages?

    When you zoom in, it is like using a magnifying glass - the underlying image remains unchanged, as you have found out.
    You may be able to enlarge the bird to some extent without distortion and without pixilation by resampling.
    Go image menu>resize>image size. Be sure that "constrain proportions " is checked in the dialog.
    More on this from the help menu:
    Photoshop Elements Help | Resizing
    If you google  this topic, you will get many hits.

  • Which is better for business Mail or Entourage 2008?

    I am new to Mac. Any advice on the better app for emails & business?
    does Mail use mbox? where does it store the email files?
    Thanks a lot in advance...

    When I transferred from a pc to a Mac, I bought the Office:Mac suite to ease the transition & used Entourage for my email.
    Having used a Mac for a few years, I now use Mail & iWork 08 for everything else. (iWork is so much more powerful than anything in the microsoft suite & the price is so much more reasonable...)
    The reason I use Mail rather than Entourage is largely due to ease of use & integration with everything else. If you use Address Book & iCal then you have already got everything you need. In the new version of Mail on Leopard, you also have the ability to create notes & to-do memos that let you add details to your iCal & set alarms or reminders. I use all this (in tandem with Bluetooth & iSync) to transfer info or update the calendars & address book on my phone, Nokia N73. You can even set birthday reminders which are good for business!
    Mail 3 comes with a bunch of good quality stationery. However, if you have any graphics skills you can build your own branded stationery & send out html mail that fully markets your brand or business identity.
    I am so glad I stopped using microsoft apps for lots of personal reasons & have never looked back.
    Good luck.

  • We have many mappings, which one is good in performance wise ?

    We have many mappings, which one is good in performance wise ?

    HI
    Different Mapping Techniques are available in XI. They are: Message Mapping, XSLT Mapping, Java Mapping and ABAP mapping.
    u2022The integration repository includes a graphical mapping editor. It includes built-in functions for value transformations and queue and context handling.  There is an interface for writing user-defined functions (java) as well.
    u2022XSLT mappings can be imported into the Integration Repository; java methods can be called from within the XSLT style sheet. Advantages of this mapping are: open standard, portable, extensible via Java user-defined functions.
    u2022If the transformation is very complex, it may be easiest to leverage the power of Java for mapping.
    u2022ABAP mapping programs can also be written to transform the message structures.
    Message Mapping
    SAP XI provides a graphical mapping tool that generates a java mapping program to be called at run time.
    u2022Graphically define mapping rules between source and target message types.
    u2022Queue-based model allows for handling of extremely large documents.
    u2022Drag-and-drop.
    u2022Generates internal Java Code.
    u2022Built-in and user-defined functions (in Java)
    u2022Integrated testing tool.
    u2022N:M mapping is possible.
    JAVA MAPPING:
    Usually Java mapping is preferred when the target structure is relatively complex and the transformation cannot be accomplished by simple graphical mapping.
    For e.g. consider a simple File->IDoc scenarion where the source file is a simple XML file, whereas the target file is an IDoc with more than one hierarchy level e.g FINSTA01. Content conversion in XI can only create a single level hierarchy, so in this scenario a Java mapping would come in handy.
    See these:
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10dd67dd-a42b-2a10-2785-91c40ee56c0b
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/thorsten.nordholmsbirk/blog/2006/08/10/using-jaxp-to-both-parse-and-emit-xml-in-xi-java-mapping-programs
    When to use Java mapping
    1) Java mapping are used when graphical mapping cannot help you.
    Advantages of Java Mapping
    1)you can use Java APIs and Classes in it.
    2) file look up or a DB lookup is possible
    3) DOM is easier to use with lots of classes to help you create nodes and elements.
    Java mapping can be used when you have complex mapping structures.
    ABAP MAPPING:
    ABAP mappings are mapping programs in ABAP objects that customers can implement using the ABAP Workbench.
    An ABAP mapping comprises an ABAP class that implements the interface IF_MAPPING in the package SAI_MAPPING. The interface has a method EXECUTE with the some signature.
    Applications can decide themselves in the method EXECUTE how to import and change the source XML document. If you want to use the XSLT processor of SAP Web AS, you can use the ABAP Workbench to develop a stylesheet directly rather than using ABAP mappings.
    In ABAP mapping you can read access message header fields. To do this, an object of type IF_MAPPING_PARAM is transferred to the EXECUTE method. The interface has constants for the names of the available parameters and a method GET, which returns the respective value for the parameter name. The constants are the same as in Java mappings, although the constant MAPPING_TRACE does not exist for ABAP mappings. Instead, the trace object is transferred directly using the parameter TRACE of the method IF_MAPPING~EXECUTE.
    For more details refer
    http://help.sap.com/saphelp_nw70/helpdata/EN/ba/e18b1a0fc14f1faf884ae50cece51b/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5c46ab90-0201-0010-42bd-9d0302591383
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e3ead790-0201-0010-64bb-9e4d67a466b4
    /people/sameer.shadab/blog/2005/09/29/testing-abap-mapping
    ABAP Mapping
    /people/udo.martens/blog/2006/08/23/comparing-performance-of-mapping-programs
    https://websmp101.sap-ag.de/~sapdownload/011000358700003082332004E/HowToABAPMapping.pdf
    /people/ravikumar.allampallam/blog/2005/02/10/different-types-of-mapping-in-xi
    /people/r.eijpe/blog
    ABAP Mapping Vs Java Mapping.
    Re: Message Mapping of type ABAP Class not being shown
    Re: Performance of mappings (JAVA, XSLT, ABAP)
    XSLT Mapping
    XSLT stands for EXtensible Stylesheet Language Transformations. It is an XML based language for transforming XML documents into any other formats suitable for browser to display, on the basis of set of well-defined rules.
    /people/sap.user72/blog/2005/03/15/using-xslt-mapping-in-a-ccbpm-scenario
    /people/anish.abraham2/blog/2005/12/22/file-to-multiple-idocs-xslt-mapping
    The above menotined are the mapping present in the XI.
    When it is critical and complicate we go for the ABAP,JAVA or XSLt mapping. For simple Mapping we go for the graphical mapping.
    the selection of mapping also depends upon the requirement and alos on our scenario.
    cheers

  • Which SSD (Solid State Drive) is good for my 2011 MacBook Pro?

    Okay I am looking for a good ssd for my macbook pro 2011 between the 150$ and 250$ price range. Which company and price would you guys reccomend?

    None, at that price it would be so small as to be practically worthless.
    You need about 500 GB to future proof and grow into, and those run about $1200-$1500
    SSD's really don't offer that much more performance, it still takes the computer 20 seconds to boot and programs still have to set themselves up so. So although the computer and programs launch a bit faster, it's not instant.
    Then to really take advantage of SSD speed, you need to have to have a large amount of files to transfer constantly, to another SSD (or else the slow hard drive slows everything down)
    So if you have 500GB to transfer to another 500GB SSD, then that would take about 30 minutes compared to a hour if you had a hard drive instead.
    And if you transfer a large amount of data often with a SSD, it wears it out prematurely. SSD's don't even have secure erase ability because allowing that would prematurely wear it out.
    So the only thing SSD's are good for are OS boot and program only drives, where little changes, place one's user files on a external 7,200 RPM drive with more space and can handle a large amount of writes and rewrites.
    Unfortuntly in a MacBook Pro you have only one space for a drive, you could use a kit to remove the Superdrive and replace it with the hard drive when you add the SSD. Problem with that is you can't boot from any OS X or Windows install disks that way.
    So there you have it, SSD is crap.
    But if you want to go the SSD + Hard drive with kit route, see Bmer (Dave Merten) who runs Mac Owners Support Group. he will walk you through it all.
    And the fastest SSD's can be found on this chart
    http://www.harddrivebenchmark.net/high_end_drives.html
    https://discussions.apple.com/message/16276201#16276201

  • Which notebook model is good for gaming?

    Hello!
    Prompt me please what better to take notebook for games from your firm?
    In advance thanks!

    Hi Dmitriy
    Well, it's not easy to say which notebook is good for gaming.
    A friend of mine has bought a Qosmio notebook and was satisfied with the performance. Also the newer Satellite notebooks are pretty performance strong.
    In my opinion if you want to play only the games and the portable factor is not very important for your so I would recommend to use the desktop PC.
    The desktop PC is easier for device and part upgrading. You can change the CPU and the graphic card. The notebook upgrading is not very easy and some parts like graphic card or CPU cannot be changed.
    Also the graphic card drivers are very important for the gaming. Notebooks manufacturers use not original graphic card manufacturer's drivers. They design own graphic drivers because of the graphic card overheating protection. Sometimes such drivers are a little bit older then newer original graphic card drivers and not compatible with the newer games.
    It's your choice.

  • My AppStore id is my apple id n password which is good when purchasing. But when I am updating from update option it ask for a password. The user id I see there is not mine, it's different. How do I change that to my apple Id? Please help me resolve .....

    My AppStore id is my apple id n password which is good when purchasing. But when I am updating from update option it ask for a password. The user id I see there is not mine, it's different. How do I change that to my apple Id? Please help me resolve  this issue. I have tried resetting it but nothing... Either I'm doing something wrong or....

    I believe the issue is with the Apple ID that was used to purchase the App. If you download an App that was purchased under a different Appple ID then all updates will also be linked to the original purchaser's Apple ID. Your Apple ID is the the same ID as your iTunes, iCloud, etc. Some folks use different ID for the different Apple sites. No need for that One ID for all Apple Sites, and if someone else buys an App using their ID and they(you) download that App onto your device and that App requires an update it will ask for the purchasers Apple ID. This happens a lot when folks sell their iPad or give it to someone else and leave some purchased(free) Apps on the iOS device. You cannot change the original ID the App was purchased under. A suggestion would be if someone else has an App that you like but do not want to pay for use their ID or in the future have them gift the App to you.

  • Guide me as a developer of iOS and also and active online game player of games like PWI, which macBook is good for me pro or air or other if any ?

    Hi,
    I am now to macBooks and dont know which one is good for me.
    Please guide me which one I have to buy.
    Regards,
    Aalok Parikh
    From India

    The retina display MacBook Pros are very lightweight, so you won't really notice a weight difference between a 15" or 13" one. If you can afford it, get the 15" notebook.
    Purchase the most powerful configuration you can afford.  If you can afford it, get the larger SSD - but, you can always get a portable external hard drive that you can take with you if you find the internal drive is too small.
    ~Lyssa

  • Which optical drive is good for my macbook air?

    which optical drive is good for my macbook air?

    That's a bit like asking what type of car you should buy ...
    I have used Apple's USB SuperDrive, and am happy with it.
    http://store.apple.com/us/product/MD564/apple-usb-superdrive

  • Which is good: ejecting or standby mode for EHD's?

    After a session at the computer, I have this dilemna: how to close down the session. At this present moment of time, I have a thunderbolt, a 2TB FW LaCie, and three Seagate [2 USB] EHD's all connected to my Mac. All the three Seagate drives have been allocated backup roles via CCC and TM.
    In this scenario, what should be the manner of my quitting a session at the computer? Will keeping the EHD's in a standby mode for prolonged periods damage them?
    Also, I would like to know what is the difference between mounting/unmounting of a drive and ejection of drive?

    somanna wrote:
    I guess I need to set my own 'protocol' in these matters.
    Indeed
    somanna wrote:
    I need to tackle my own 'temporary laziness' and take time to do these things: eject the thunderbolt drive which I use for editing videos in FCPX. [After doing an 'eject' do I have to also disconnect the power supply by pulling out the thunderbolt cable from the drive? By so doing, the CCC based backup would not take place.
    No it should go into standby without disconnecting it.
    That is correct, if it is disconnected then CCC will not backup. If you are using the same drive for editing and CCC, then you will need to test it to see if CCC will bring it backup from standby. If not, then maybe that is not a good combination of uses for one drive.
    somanna wrote:
    My LaCie has a power switch. Is it okay to directly switch it off or do I have to first click upon its desktop icon and eject it? But if I switch off its power, then will CCC automatically start up the power and at its set time backup the data on this Lacie to its concerned backup drive, a Seagate?
    No you should first Eject it before Switching it off.
    No CCC will not turn it back on.
    No
    somanna wrote:
    The 2 other Seagate drives also have got some functions to do regarding backups. These Seagate drives have no power switches. Should I just eject these drives and keep their power cables on or do I have to also have to remove their power supply cables from the drives after they are ejected.
    As with any automated backup, the drive(s) must be connected and powered on in order for the automated backup to take place.
    somanna wrote:
    Further guidance and instructions in these matters will be highly appreciated.
    While I also get a little anal about backup, I do like to save power whenever I can.
    To be honest, I would probably only use the Thunderbolt drive for editing and keep one other drive online to back it up. Then rotate the other drives in and out on a daily or weekly basis keeping them off line, off site or at least in a firesafe.
    Keep at least one or two aces up your sleeve! Heck' a single lighting strike, power surge or simple mistake could take out everything in the blink of an eye if it's all hooked together and running.

Maybe you are looking for