×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Regular Contributor
    Join Date
    May 2009
    Posts
    95

    Performance question...

    Hi friends,

    This is a question about something that came to mind to try to improve the performance of a midlet.

    In your opinion which is the best approach:

    1) Use System.getProperty("microedition.platform") each time i need that information

    OR

    2) Save the value in a global variable and retrieve it each time needed

    I think that the 1st one use less memory and the 2nd one executes faster...

    Any other comments guys ? I think that i would go for the 2nd approach because it's much cleaner code and it executes faster. But i would appreciate if maybe there are some of you who have some other ideas about these different approaches...

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Performance question...

    Option (2) will be significantly faster. It will cost you four bytes.

    Better still, don't save the value, but save some useful piece of information based on that value.

    Graham.

  3. #3
    Regular Contributor
    Join Date
    May 2009
    Posts
    95

    Re: Performance question...

    Mmm i thought so but i said i should check what people with more experience think heh

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Performance question...

    Remember that you're not making a copy of the string, just a copy of the object reference (four bytes). So the memory cost is negligable.

  5. #5
    Regular Contributor
    Join Date
    May 2009
    Posts
    95

    Re: Performance question...

    Mmm thats an interesting fact, because to say the truth i never knew that an object reference is just 4 bytes...

    Btw just to be safe, can: System.getProperty("microedition.platform") ever be null ?? On any phone in the world !!

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Performance question...

    The only rule about the value for microedition.platform is in JSR-248 (MSA), which specifies a format for the string - manufacturer name followed by model with no separator between (like "Nokia7210"), optionally followed by a "/" and additional information.

    Other devices could potentially return null, though I can't think of any off hand. Many devices do just return "j2me".

  7. #7
    Regular Contributor
    Join Date
    May 2009
    Posts
    95

    Cool Re: Performance question...

    Quote Originally Posted by grahamhughes View Post
    The only rule about the value for microedition.platform is in JSR-248 (MSA), which specifies a format for the string - manufacturer name followed by model with no separator between (like "Nokia7210"), optionally followed by a "/" and additional information.
    I wish there was an international standard for all phones, to return a standard formatted string like "make_model_etc..." :-/

  8. #8
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Performance question...

    There is: JSR-248. Unfortunately, the original CLDC spec doesn't specify a format. Believe me, that omission is the least of J2ME's problems...

  9. #9
    Regular Contributor
    Join Date
    May 2009
    Posts
    95

    Re: Performance question...

    Quote Originally Posted by grahamhughes View Post
    There is: JSR-248.
    So howcome some phones return J2ME and others return null ? If there's a standard...

  10. #10
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Performance question...

    It's a new standard. It was never in the original CLDC specification. There's also no rule that says phone must comply with any given standard.

  11. #11
    Regular Contributor
    Join Date
    May 2009
    Posts
    95

    Re: Performance question...

    Sure there's not rule but i don't find a single reason why not to comply with such a standard. I mean certain type of software, like the one that i'm working on, isn't able to be 100% dynamic depending on the phone make...

    And i believe that for certain other type of software such information can be vital for certain known issues of certain phone makes / models...

  12. #12
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Performance question...

    yeah you might think the same about getting IMEI (might be vital to uniquely identify a device), guess what ? Thats no standard either.. SOme people find it vital to get the devices phine number.. again no standard...
    The CLDC/MIDP standards themselves are used on Java Devices, but those weren't specifically written for Java mobile phones, just "small devices"...
    So just take into account you will encounter more of those "illogical" missing information-retrieveing methods/api's...

Similar Threads

  1. question about global var's performance in dll?
    By ptclin_2007 in forum Symbian
    Replies: 0
    Last Post: 2008-04-11, 10:48
  2. N81 BUG: Web Services Parser an question marks???
    By masterchief2004 in forum Mobile Java General
    Replies: 1
    Last Post: 2008-03-07, 17:59
  3. Performance investigator question
    By riussi in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2008-01-28, 09:15
  4. Replies: 0
    Last Post: 2003-04-07, 09:52
  5. Question on support of dll's
    By sanju_v in forum Symbian
    Replies: 1
    Last Post: 2003-03-05, 13:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×