Small efficiency question

Does using braces for containing if's and for's etc affect the efficiency or size of compiled binary code?
e.g.
Does this make a difference:
for( int i=0; i<N; i++ ) {
b += f;
As opposed to:
for( int i=0; i<N; i++ )
b += f;

Actually you will get a speed increase by a factor of
10 to 15 if you manage to write your application on
only one line.
:)Example 1:
public class Test {
  public static void main(String[] args) {
    System.out.println("WTF?");
}vs Example 2:
public class Test{public static void main(String[] args){System.out.println("WTF?");}}So far my performance tests have proved inconclusive, but I'll be sure to write all my code like example 2 from now on : )

Similar Messages

  • Efficiency Question - Cutting Clips

    Efficiency Question - Cutting Clips.
    So I was wondering if there is a better way to cut my clips that I am not using. Basically I often have large long clips of raw footage that I cut down to the usable segments. Each raw file may be over an hour long and have 100s of small segments of live commentary, often I find I am cutting out slightly to long pauses in the talking and other stuff before I have a clip ready to send to the main edit.
    Anyway, often I am zoomed will in so I can edit, and I press C, make a cut.. then make another a bit further up, press V, click on the segment I just cut out.. press delete and then click on and move the rest of the raw clip to the left to bump up where I made the first cut, often needing to zoom well out and then back in again to continue editing.
    Is there a better way to do this? So I do not need to zoom in and out all the time... is there a way to delete a chunk of video form the sequence and have the clip automatically "close the gap" for me?
    --Thanks

    I would take the Source Clip into the Source Monitor.
    Mark an In Point  ("I")  where the good content starts...and an Out Point ("O")  where the good content stops.
    Hit "," to Insert it to the Sequence.
    Back to Source Monitor and repeat for the next section of good content in the same Source Clip..
    No gaps . Done
    Then ..if necessary...I would play thru  the Sequence and do Trim Edits at the editpoints.
    Many different ways to "skin the cat" at Trim stage.
    Alternatively in the first part:
    I would take the Source Clip into the Source Monitor.
    Mark an In Point ("I") where the good content starts...and an Out Point ("O") where the good content stops.
    CTRL-Drag to the Program Monitor.

  • I have a question regarding a small blue question mark instead of photo, I asked about this and was directed to a question about text edit, which, by the way, a neighbour helped with.

    Email photographs not seen, photograph are replaced with a small blue question mark.....what do I need to do to see the pictures ?

    Hello tomfromridgetown,
    Welcome to the Apple Support Communities! 
    I understand that sometimes when you receive an email it contains a small box with a question mark for the attachment. It sounds like what you may be seeing is a windmill.dat attachment. Please review the attached article for information on what these attachments are and how to avoid them in the future. 
    Mac OS X Mail: What is a winmail.dat attachment? - Apple Support
    Have a great day,
    Joe 

  • Efficiency Question: Simple Java DC vs Used WD Component

    Hello guys,
    The scenario is - I want to call a function that returns a FileInputStream object so I can process it on my WD view. I can think of two approaches - one is to simply write a simple Java DC that does so and just use it as a used DC so I can call the functionality from there. Or create another WD DC that exposes the value (as binary) via component interface.
    I'm leaning on the simple Java DC approach - its easier to create. But I'm just curious on what would be the Pro-side (if there's any) if I use the WD Component interface approach? Is there a plus for the efficiency? (Though I doubt) Or is it just a 'best/recommended practice' approach?
    Thanks!
    Regards,
    Jan

    Hi Jan
    >one is to simply write a simple Java DC that does so and just use it as a used DC so I can call the functionality from there
    Implemented Java  API for the purpose mentioned in your question is the right way, I think. The Java API can be even located in the same WebDynpro DC as your WebDynpro components. There is not strongly necessity to put it into separate Java DC.
    >Or create another WD DC that exposes the value (as binary) via component interface
    You should not do this because in general WD components' purpose is UI, not API. Implementing WD component without any UI, but with some component interface has very-very restricted use cases. Such WD component shall only be a choice in the cases when the API is WebDynpro based and if you have to strongly use WebDynpro Runtime API in order to implement your own API.
    If your API does not require WebDynpro Runtime API invocations or anything else related to WebDynpro then your choice is simple Java API.
    >But I'm just curious on what would be the Pro-side (if there's any) if I use the WD Component interface approach? Is there a plus for the efficiency?
    No. Performance will be better in simple Java API then in WebDynpro component interface. The reason is the API will not pass thought heavy WebDynpro engine.
    BR, Siarhei

  • Advice for Building Small Network Question

    Hello,
    I am building a small network environment which will connect to a larger office, scalability is important.  We will begin having about 30 users which will all need VOIP services.  The VOIP services will be hosted by a cloud provider.  My question is as of now I am looking to obtain a Cisco 2921 ISR Router and then a Cisco 2960-X 48Gig POE, and my main question is I am confident the switch can handle the power and operation of the phones but just to make sure I should not run into any problems with the router as far as forwarding the data, correct?  Any other comments or suggestions would be appreciated.
    Thanks,
    Joe

    Duplicate post. 
    Go HERE.

  • Noobish "efficiency" question on DataOutputStream

    So, I currently have this:
    byte[] buf = some_bytes;
    DataOutputStream out = new DataOutputStream(socket.getOutputStream());
    out.writeInt(buf.length);
    out.write(buf);I've always thought that calling write(byte[]) and any given OutputStream will be "efficient", in that things will be chunked under the hood to avoid incurring whatever I/O overhead is present for each and every byte. So, as I understand it, we only need to explicitly use BufferedOutputStream if we're writing one or a few bytes at a time.
    Now I'm not so sure.
    Digging through the core API source code a bit, it seems that this ultimately calls OutputStream.write(byte) in a loop, which, presumably, is bad unless the OutputStream in question is a Buffered one.
    Am I shooting myself in the foot here? Should I be wrapping that DataOuputStream around a BufferedOutputStream? Or vice versa?
    Or should I just scrap the DataOuputStream altogether and write the int's bytes out myself?
    I'm going to test it both ways, but in the meantime, and just in case the tests are not definitive, I'm wondering if anybody here can tell me what I should expect to see.
    I think I've been staring at this stuff for a bit too long and am second-guessing myself to death here no matter which way I look at it. So thanks in advance for any nudge you can give me back toward sanity.
    Edited by: jverd on Feb 16, 2012 3:59 PM

    EJP wrote:
    So, what's the point of the basic OutputStream not being buffered then?I guess the idea was that if you want buffering you say so,Ok.
    I think you'll find that every significant class that extends OutputStream (specifically FileOutputStream and SocketOutputStream) overrides write(byte[], int, int) to do an atomic write to the OS, so it isn't really such an issue except in the case of DataOutputStream (and not ObjectOutputStream, see above).Okay, so, in this case, I've got a DataOutputStream wrapped around a SocketOutputStream. It's not an issue for SOS, but it is for the wrapping DOS. Yes?
    So to overcome the DOS doing a bunch of piddly 1-byte writes to the SOS, which in turn could result in a bunch of piddly 1-byte writes to the network, which I don't want, I inject a BOS between them. Yes?
    Thanks for the help. I can't believe after all these years I never got these details sorted out. I guess it never came up quite this way before.

  • Hash Table efficiency question

    Hi experts,
    In my program, I want to read in a lot of string and store the occurance of each string. I found that hash table is the best and most efficient option, but the problem is that, hash table only store one item.
    So, I either have to:
    1) store an array object into each hash table entries. ie String[String][Occurance]
    2) create two hash table based on the hash code of the string.
    For 2) I am planning to store all distinct String into one hashtable using the string as the hashcode, then create another hashtable to store the occurance using the String as the hashcode.
    My question is that:
    1)which implementation is more efficient? Constantly creating String array for each entry or create two hashtables?
    2) Is the second implementation possible? Would the hashcode be mapped to different cell in the hashtable even the two hashtable are using the same hashcode and the same size?
    Thank you very much for your help.
    Kevin

    I am wondering what it is you are trying to do, but I am assuming you are trying to find the number of occurrences for a particular word, and then determining which word has the highest value or the lowest value? You can retrieve the initial String value by using the keys() method of the hashtable. You can use it to traverse the entire table and compare the counts there.
    If you really wanna store another reference for that string, create a simple object
    public final class WordCount {
       * The Word being counted.
       * @since 1.1
      private String _word;
       * Count for the Number of Words.
       * @since 1.1
      private int _count;
       * Creates a new instance of the Word Count Object.
       * @param word The Word being counted.
       * @since 1.1
      public WordCount(final String word) {
        super();
        _word = word;
        _count = 0;
       * Call this method to increment the Count for the Word.
       * @since 1.1
      public void increment() {
        _count++;
       * Retrieves the word being counted.
       * @return Word being counted.
       * @since 1.1
      public String getWord() {
        return _word;
       * Return the Count for the Word.
       * @return Non-negative count for the Word.
       * @since 1.1
      public int getCount() {
        return _count;
    }Then your method can be as follows
    * Counts the Number of Occurrences of Words within the String
    * @param someString The String to be counted for
    * @param pattern Pattern to be used to split the String
    * @since 1.1
    public static final WordCount[] countWords(final String someString, final String pattern) {
      StringTokenizer st = new StringTokenizer(someString, pattern);
      HashMap wordCountMap = new HashMap();
      while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (wordCountMap.containsKey(token)) {
          ((WordCount) wordCountMap.get(token)).increment();
        } else {
          WordCount count = new WordCount(token);
          count.increment();
          wordCountMap.put(token, count);
      Collection values = wordCountMap.values();
      return (WordCount[]) values.toArray(new WordCount[values.size()]);
    }Now you can create your own comparator classes to sort the entire array of Word Count Objects. I hope that helps
    Regards
    Jega

  • IMac screen gone white with small flashing question mark in centre of screen

    iMac screen went blank (greyish white) on startup and now has a small question mark flashing in the middle of the screen.
    Any idea what I should do?

    Thank you.
    Was just trying the routh of a USB keyboard & mouse and by holding down the 'option' key, the request for wireless network popped up; after connecting, 'internet support' popped up and now it's showing a small rotating globe and a horizontal hourglass with 1:23 to go still....
    Let's see how this does

  • I'm looking for a new small, efficient media player.

    Hi there.
    The background that will give you insight into my situation but doesn't need to be read
    I come from a very cushioned past media-wise. When I really started to get into listening to music I was still using Windows. It was Winamp first, which I liked but found a little much, but a few coincidences later found XMPlay, a free but closed-source media player capable of playing not only some weird file formats such as MO3, MOD, IT, XM, S3M etc, of which I have a few files in this format, but also MP3, OGG, WAV, and all the other general stuff out there. The timing was just perfect and I "grew" into my "media years" with this player. I used it across my transition from Win98 to XP, and also used it on a Win95 laptop - and I don't even think I had to "help" the system "like" the player to make it work, although I could be wrong.
    However, XMPlay has no Linux version, and as far as I can see, no porting is planned. And as I said before, it's closed source, so not much can be done there.
    In my setup I had a machine set aside for media playback because it had a SB16 in it, and I'd run it with the bass set to 100% and treble set to 0%. Despite what you might think, the output was awesome with headphones - it could give me a good headache or two without distorting at all.
    So, when I first switched to Linux, I didn't initially switch this machine over, but left it running Win98. This got to me in the end so I switched it over... and immediately faced issues. Since there was no port of XMPlay, I needed to find a new player, and fast. XMPlay has a bunch of audio postprocessing features I had enabled, none of which I found support or equivalents for in Linux (for example, an EQ setting promoting bassboost, in addition to that provided by the card - you can understand the headaches). I eventually gave up and ran XMPlay using WINE... and left it that way, for several months. I mean, it worked, didn't it? Then the fact that XMPlay over WINE on a 450MHz processor (it's a P3, haha) used 50%+ CPU -minimum- for the player to even be running (IIRC) got to me, so I decided once again that a new player had to be found. After some digging, I found XMMS to be the most likely candidate (it supports LADSPA and I could configure a bass-boost filter), and for the most part, it worked well. Quite well.
    Then... after I recently found myself recording some audio from the SB16's output to my main machine's input (the simplest way to get around the issue that the bass boost isn't very easy to feed back into the card - or impossible, I haven't tried it for so long), and had my headphones connected to my desktop to monitor the recording. Then, after that was done, I somehow started listening to some other piece of music (through my main box), for whatever reason. I immediately noticed a rather stark contrast in quality to what I'd recorded from the SB16 and what I was listening to. A doublecheck later confirmed that yes, my SB16 was of terrible quality, and yes, I needed a solution, since I wasn't gonna listen to that kinda sound quality anymore now that I knew.
    Over the past few weeks (months?) up until this point I've slowly been weaning myself off the music I liked so much (XMs and MODs, and maybe the occasional S3M), and the postprocessing features I thought had glued themselves into my ears....
    The, uh, like, point.
    ....so I need a media player that doesn't have much in terms of sound processing, but meets all the following requirements, either built in or as a plugin (as logically applicable):
    * Can hide completely, leaving only a hotkey to bring it back. I don't use a system tray and don't want to, for any purpose.
    * Is written in a compiled language.
    * Has configurable global hotkey support
    * Isn't bloated, dependancy-wise, filesize or memory-wise, or desktop-real-estate-wise - something that uses basic C and has a basic GUI preferred
    * Controls the hardware volume so that volume changes are instant
    * Supports tracks longer than 60 minutes / 1 hour
    * Has good file management / playlist support
    * Is something I can throw a gigantic directory tree at and expect to load all the music in it, FAST. I could throw my entire 32GB HDD at XMPlay when I wanted to see/remember what new music was on it and I'd just leave it alone for slightly under 5 minutes. When I returned to it, bam, playlist. That was on the 450MHz P3, running Win98. XMPlay also gave me feedback - if you can recommend something that shows me where it is on the filesystem, that'd be great.
    Up until now, Audacious has met those requirements. But it's had the following issues:
    * The track details window won't open for random tracks
    * The time display stuffs up for tracks longer than >60m, showing the position at 0:59, then, 1:40, then after 10 minutes have passed 1:41, etc
    * The volume control randomly forgets how to change the volume, and I refuse to change the controller to use a software volume since it'll induce delays
    * The system has no ability to add directories recursively - this was present in XMMS, but the BMP guys removed it (?!?!?!) and since Audacious is a fork of BMP, ...
    * The latest version's global hotkeys plugin restores the window to a non-changeable location when I use the "toggle player windows" function. As a visual person I find this a huge blocker.
    Now for the list of players that don't do what I want. XD
    * mpd - expects all your files to be in one folder; mine are everywhere, even thrown across sshfs mounts to other systems.
    * audacious - ...
    * xmms - too boring. GTK1. old stuff. unsupported.
    * xmms2 - seems too "unreachable". I haven't tried this player yet, mostly because Arch has no clients in the repos. *stab*
    * banshee - 200TB of dependencies, and it needs 400TB of RAM to run. Read: I dislike Mono.
    * rhythmbox, banshee, amarok, exaile, quod libet - iTunes-ey UI. I hate iTunes-ey UIs.
    * songbird - depends on the Gecko rendering engine. I have 512MB RAM, and I already run Firefox, thanks.
    * bmp, xmms, audacious - winamp-ey UI. I want to move away from winamp-ey UIs.
    If you have any suggestions... I'll be amazed.
    -dav7
    Last edited by dav7 (2008-09-09 12:55:22)

    * Can hide completely, leaving only a hotkey to bring it back. I don't use a system tray and don't want to, for any purpose.
    Sonata, disable system tray icon, modify any panel settings to ignore it
    * Is written in a compiled language.
    mpd is written in C
    * Has configurable global hotkey support
    Set up keybindings for mpc commands
    * Isn't bloated, dependancy-wise, filesize or memory-wise, or desktop-real-estate-wise - something that uses basic C and has a basic GUI preferred
    mpd uses basic C, many, many GUIs for it around, extremely small memory footprint
    * Controls the hardware volume so that volume changes are instant
    Keybind alsamixer commands
    * Supports tracks longer than 60 minutes / 1 hour
    Is there a modern media player that doesn't do this?
    * Has good file management / playlist support
    I never use mpd's playlist capabilities, but they do seem fairly extensive.
    * mpd - expects all your files to be in one folder; mine are everywhere, evn thrown across sshfs mounts to other systems.
    Apparently you have never heard of symbolic links. OH SNAP! Just create a single directory to collect all the links in. Also, mpd does not expect everything to be in one folder; it expects everything to be available from one parent folder, allowing you to organize beneath that parent.
    The problem you're having isn't that you're looking for a music player, you're looking for a wm/media player/file manager, and that just doesn't exist on Linux, largely because we are sane (for the sake of argument, ignore Songbird right now, I don't think any of us are crazy enough to use it anyways). Like looking for a zebroctonoceros, even though a zebra exists, an octopus exists, and a rhinoceros exists, they do not exist in the same creature. For interfacing with X (keybindings and the disappearing music player), you're better off going through a configurable wm like Openbox. For the actual music playing, well, I don't see any problems with mpd besides your music files being messy, and you can't expect music playing software to solve a personal organization problem. If your file system is messy, then use a file manager to fix it, not your mp3 player. I put a lot of effort into keeping my music files properly tagged and accessible from a single top level directory called music, which then splits off into mp3/ogg files, flac files, podcasts, etc, and that largely solves the problem of wondering where s--t is.
    Another idea for you, if you have multiple machines. Collect all your music onto a single machine, and then set up that system to serve exclusively as an mpd jukebox you can listen to from your other computers over the network. Give it a try.
    Last edited by coarseSand (2008-09-11 16:03:31)

  • Small inheritance question

    Got a small quesiton about inheritance.
    I have a 'User' Class and extending that class is 'Player' and 'Enemy'.
    Player class and Enemy class contains extra stuff like different image and moves different.
    When I create a new player do I create an instance of the 'User' class or the 'Player' class?
    Also,
    If values change in the 'Player' class do the values also change in te 'User' class?
    I am fairly new to java.
    Thanks

    MarcLeslie120 wrote:
    Got a small quesiton about inheritance.
    I have a 'User' Class and extending that class is 'Player' and 'Enemy'.Sounds odd. Aren't some players also your enemy? Or is Player me, and everybody else is Enemy?
    Player class and Enemy class contains extra stuff like different image and moves different.Okay. If it's just different, that's one thing. If it's adding extra methods, you probably don't want to inherit.
    When I create a new player do I create an instance of the 'User' class or the 'Player' class?If it's going to be a Player, you need to create a Player.
    If values change in the 'Player' class do the values also change in te 'User' class?If you mean an instance variable (a non-static member variable), then there aren't two separate objects. There's just one object, that is both a Player and a User. The variable exists only once.
    Your inheritance hierarchy smells funny, but without more details about what these classes represent and what you're trying to accomplish, it's hard to provide concrete advice.

  • ABAP efficiency question

    Hi
    I have an internal table of the type STRING which may contain thousands of records and I am trying to get to lines which starts with a set of characters. There may be a few lines starting with that sequence and it is possible to do what I have shown below, however, is there a more efficient way to do this?
    Ideally what I would like to do is to find the lines or the index (SY-TABIX) using LOOP AT.......WHERE....My current way of doing it is not the best. Any ideas?
    DATA t_spooltext TYPE TABLE OF string. "contains thousands of lines
    DATA l_text(200) TYPE c.
    DATA l_index     TYPE i.
    LOOP AT t_spooltext INTO DATA(l_current_line).
      CONDENSE l_current_line.
      l_text = l_current_line.
      IF l_text+0(5) EQ 'H046A'.
        l_index = sy-tabix.
        ELSE
            CONTINUE.
      ENDIF.
    ENDLOOP.

    Sharath,
    Fixing what you posted, I add the sample code below:
       REPORT  z_test.
    DATA: t_spooltext TYPE TABLE OF string,
          results_tab TYPE TABLE OF match_result.
    DO 10 TIMES.
      APPEND 'H046A' TO t_spooltext.
    ENDDO.
    DO 3 TIMES.
      APPEND 'H046B' TO t_spooltext.
    ENDDO.
    FIND ALL OCCURRENCES OF 'H046A'
    IN TABLE t_spooltext
    IN CHARACTER MODE
    RESULTS results_tab.
    BREAK-POINT.
    Archana, in my point of view the user Sharath are correctly, only thing you have to watch is the form that is set to result table, as I showed above

  • Small Text Question

    I'm trying to create a document with text sizes smaller than 6 pt. The problem is that the "Other" option in the drop-down menu is grayed out and I don't know why. I tried several different fonts and different types of fonts, but they all had the same problem.
    For the moment, I'm creating my text in Illustrator, then cutting and pasting it into InDesign, but I'd rather just create it in InDesign directly.
    Any help would be appreciated.

    Didn't read the part about the drop-down menu. Was just looking in the character palette. Nonetheless, it may be the same thing. If the Other field in Cindy's character palette is greyed out as well, which I'm guessing it is, inputing a value there may jump start the whole thing.

  • Catalog efficiency question in Lightroom 3.6

    I currently have one catalog with over 22,000 photos and numerous collections in it. I recently heard about creating separate "catalogs" to better LR3's efficiency and to cut down the clutter so that I'm just working on one catalog at a time. Does anyone know the best way to go about this so as not to ruin all of my collections I have created over the past year?

    Don't do it is the answer. For most uses one catalog is the best solution.

  • IPhone 3G  uses Smaller Battery / Question

    According to this tear down:
    http://live.ifixit.com/Guide/First-Look/iPhone3G
    The battery is actually lower in capacity than of the original iPhone.
    My question is: Would it be possible to replace the included Battery with a larger size?

    Ouch! That's certainly a bummer... why would Apple do this? If they complain 3G ***** down more battery (the reason why 3G was not included in the original iPhone, and the fact that the 3G settings screen says it too), you would think that the iPhone 3G would have at least the same battery capacity if not more.
    I think this is a conspiracy to get people to subscribe to mobile me to get push email instead of people like me who set my phone to fetch mail every 15 minutes. My battery on the iPhone 3G is down to 10% at night with very little use throughout the day (other than checking mail and a couple of phone calls). And I only have 1 email account set up.
    Compared to my original iPhone, I have 3 email accounts that are checked every 15 minutes, and I'm usually at 40% battery left when I go to bed at night.

  • Program efficiency question

    Hello all, I was just wondering about the efficiency of some programming practices. I have a program I am working on with about 20 different files. One of the files contains all of my constants ("Constants.java")... I am wondering if it is a bad practice to just call all of the variables statically i.e.
    System.out.println(Constants.menu);
    or would it be more efficient for the classes that use Constants to implement Constants?? I believe in that case I would be able to just use:
    System.out.println(menu);
    As of right now I am using the 1st method, but I wasn't anticipating the growth of the program to be so large. Any input on this subject would be greatly appreciated. Thanks,
    dub

    or would it be more efficient for the classes that
    use Constants to implement Constants?? No.
    Using interfaces for constants is an antipattern.
    Don't dwell on these micro "efficiency" issues. Write code that's simple and easy to understand. Worry about performance in broader terms--e.g., prefer an O(N) operation to an O(N^2) one. Only diddle with those minutuae if you've determined that they're actually causing problems and the change you make will create a significant improvement.

Maybe you are looking for

  • Crystal Reports for Eclipse and CR2008 with subreports

    SQL-Server 2005 CR 2008, Ver.12.0.0.683 Crystal Reports for Eclipse Plug-in Details: all Plug-in-files from Business Objects have the version 12.2.200.r454 I create a report with subreports in CR2008. It's running perfect. When I load this report wit

  • Cursor in another cursor. how?

    i have a program like this DECLARE V_VARIABLE1 VARCHAR2(10); CURSOR_ABC IS select...............; BEGIN OPEN CURSOR_ABC; LOOP FETCH CURSOR_ABC INTO V_VARIABLE1; EXIT WHEN CURSOR_ABC%NOTFOUND; WHAT IF I WANT TO INSERT ANOTHER SAME KINDA CURSOR LOOP HE

  • Debit Invoice split, based on split analysis refering to payment reference in header

    Hello Experts, When debit memo request process for billing through SDBILDL due list job, debit invoice split and when I check in silt analysis it is referring to payment reference for split criteria and both the invoice carries same payment terms fro

  • Photoshop CS6 No lens profiles (lens correction filter) for Canon 6D raw files

    LightRoom and Camera Raw have profiles for Lens Correction and all the current available lens are  in the list for the Canon 6D raw files. BUT the Filter/Lens Correction when in Photoshop CS6 only have 2 Tamron lens listed. Odd that there are lens pr

  • Isight in imovie HD

    i have the new imac G5 with the built in isight and im trying to record live video in imovie HD but its not recognizing the isight camera. in the help menu, its telling me to turn on the shutter privacy. how do i do that?