Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8495175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:29:59+00:00 2026-06-10T23:29:59+00:00

The javascript code that is generated by GWT for HashMap.iterator() and HashSet.iterator() are very

  • 0

The javascript code that is generated by GWT for HashMap.iterator() and HashSet.iterator() are very very slow. Is there a way to speed it up?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:30:01+00:00Added an answer on June 10, 2026 at 11:30 pm

    Very very slow? You’ll have to be a little bit more specific. Here’s a little example that sums up 100000 numbers:

    final int N = 100000;
    
    final long startInsert = System.currentTimeMillis();
    
    final HashSet<Integer> set = new HashSet<Integer>(N);
    for (int i = 0; i < N; i ++)
      set.add(i);
    final long stopInsert = System.currentTimeMillis();
    
    RootPanel.get().add(new Label(
        "Time to insert: " + (stopInsert - startInsert) + "ms"));
    
    final long startIterate = System.currentTimeMillis();
    final Iterator<Integer> iterator = set.iterator();
    
    int sum = 0;
    while (iterator.hasNext()) {
      final Integer integer = iterator.next();
      sum += integer;
    }
    
    final long stopIterate = System.currentTimeMillis();
    RootPanel.get().add(new Label("Sum: " + sum + 
        ", Time to iterate: " + (stopIterate - startIterate) + "ms"));
    

    Let’s try this on a Core2 Duo:

    Here’s the output in Firefox 15 (compiled mode):

    Time to insert: 490ms
    Sum: 4999950000, Time to iterate: 766ms 
    

    And Chrome 21 (compiled mode):

    Time to insert: 130ms
    Sum: 4999950000, Time to iterate: 105ms
    

    That’s slower than in dev mode:

    Firefox 15 (dev mode):

    Time to insert: 16ms
    Sum: 704982704, Time to iterate: 12ms
    

    Chrome 21 (dev mode):

    Time to insert: 59ms
    Sum: 704982704, Time to iterate: 10ms
    

    But considering, that this is JavaScript vs Java, the results are actually pretty good.

    (BTW, in case somebody wonders why the sum is different in Java (704982704) compared to JavaScript (4999950000)… this is expected, see https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsCompatibility#language)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found that the more than 60% of the javaScript code generated by GWT
For Javascript code that is linked or generated, what is the best way to
I have a trivia page that is dynamically generated by some javascript code. It
I am working on debugging some javascript code that is generated in Yesod. Yesod
I'm writing some Javascript code that generates an XML document in the client (via
I have the following Javascript code that works perfectly: $(document).ready(function() { $(#Select1).setDefault(); $(#Select2).setDefault(); $(#Select3).setDefault();
I have seen Javascript code that uses parenthesis immediately after a function's closing curly
I have a javascript code that have span tag and inside the span tag
I have some Javascript code that will programmatically register an COM interop assembly by
I have some JavaScript code that works in IE containing the following: myElement.innerText =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.