Loading ...
Sorry, an error occurred while loading the content.

Loop Benchmarks

Expand Messages
  • berg.matt
    Pretty interesting, especially if it can help improve speed. http://blogs.sun.com/greimer/resource/loop-test.html
    Message 1 of 5 , Jul 29, 2008
    • 0 Attachment
      Pretty interesting, especially if it can help improve speed.

      http://blogs.sun.com/greimer/resource/loop-test.html
    • darren_kovalchik
      I saw this a few days ago as well. Didn t think about applying it to Taffy though. Nice thinking! What s really interesting to me is that (on my machine)
      Message 2 of 5 , Jul 29, 2008
      • 0 Attachment
        I saw this a few days ago as well. Didn't think about applying it to Taffy though. Nice thinking!

        What's really interesting to me is that (on my machine) simply running the for loop in reverse yields at least double the speed across all tests in all browsers. Looks like it could be an easy way to speed up Taffy.

        I plugged reverse for loops into my copy of Taffy, ran the included speed test on a DB of 5000 records and ended up with the following:

        Create and Fill Taffy - 7% speed increase
        Do 80% record remove via lookup - 32% speed increase
        Do a forEach Update - 2% speed decrease
        Find Every Record - 28% speed increase
        Find Record 900 - 2% speed decrease
        Sort by Value Desc - 3% speed increase

        Then I did the same thing with a DB of 1000:

        Create and Fill Taffy - 4% speed increase
        Do 80% record remove via lookup - 25% speed increase
        Do a forEach Update - 0.5% speed increase
        Find Every Record - 26% speed increase
        Find Record 900 - 5% speed increase
        Sort by Value Desc - 7% speed increase


        Accounting for general margin of error, the 80% remove and finding every record gained a lot from this quick change. I was sort of surprised that finding a single record didn't receive any speed bumps, but I haven't had time to really look into that. Also, this test was using version 1.4 originally. I changed the version of Taffy it was using, but didn't look at the syntax of the tests, so there might be some discrepancies I'm not aware of.

        At any rate, it does show that with a bit of testing, using a reverse for loop could garner some fairly significant speed gains with minimal changing of the current code base.


        --- In taffydb@yahoogroups.com, "berg.matt" <berg.matt@...> wrote:
        >
        > Pretty interesting, especially if it can help improve speed.
        >
        > http://blogs.sun.com/greimer/resource/loop-test.html
        >
      • berg.matt
        Thanks for running those tests so quickly. Pretty interesting results. Matt
        Message 3 of 5 , Jul 31, 2008
        • 0 Attachment
          Thanks for running those tests so quickly. Pretty interesting results.

          Matt

          --- In taffydb@yahoogroups.com, "darren_kovalchik" <kovalchik@...> wrote:
          >
          > I saw this a few days ago as well. Didn't think about applying it to
          > Taffy though. Nice thinking!
          >
          > What's really interesting to me is that (on my machine) simply running
          > the for loop in reverse yields at least double the speed across all
          > tests in all browsers. Looks like it could be an easy way to speed up
          > Taffy.
          >
          > I plugged reverse for loops into my copy of Taffy, ran the included
          > speed test on a DB of 5000 records and ended up with the following:
          >
          > Create and Fill Taffy - 7% speed increase
          > Do 80% record remove via lookup - 32% speed increase
          > Do a forEach Update - 2% speed decrease
          > Find Every Record - 28% speed increase
          > Find Record 900 - 2% speed decrease
          > Sort by Value Desc - 3% speed increase
          >
          > Then I did the same thing with a DB of 1000:
          >
          > Create and Fill Taffy - 4% speed increase
          > Do 80% record remove via lookup - 25% speed increase
          > Do a forEach Update - 0.5% speed increase
          > Find Every Record - 26% speed increase
          > Find Record 900 - 5% speed increase
          > Sort by Value Desc - 7% speed increase
          >
          >
          > Accounting for general margin of error, the 80% remove and finding every
          > record gained a lot from this quick change. I was sort of surprised that
          > finding a single record didn't receive any speed bumps, but I haven't
          > had time to really look into that. Also, this test was using version 1.4
          > originally. I changed the version of Taffy it was using, but didn't look
          > at the syntax of the tests, so there might be some discrepancies I'm not
          > aware of.
          >
          > At any rate, it does show that with a bit of testing, using a reverse
          > for loop could garner some fairly significant speed gains with minimal
          > changing of the current code base.
          >
          >
          > --- In taffydb@yahoogroups.com, "berg.matt" <berg.matt@> wrote:
          > >
          > > Pretty interesting, especially if it can help improve speed.
          > >
          > > http://blogs.sun.com/greimer/resource/loop-test.html
          > >
          >
        • tacoman_cool
          Thanks Matt and Darren. Very cool information. By and large I ve gotten the best result from this loop: var i = arr.length; while (i--) { } That should work
          Message 4 of 5 , Jul 31, 2008
          • 0 Attachment
            Thanks Matt and Darren. Very cool information.

            By and large I've gotten the best result from this loop:

            var i = arr.length; while (i--) { }

            That should work for most of the loops if adopted. Any thoughts on
            this vs the reverse for loops? Should we adopt it in 1.7?

            --- In taffydb@yahoogroups.com, "berg.matt" <berg.matt@...> wrote:
            >
            > Thanks for running those tests so quickly. Pretty interesting results.
            >
            > Matt
            >
            > --- In taffydb@yahoogroups.com, "darren_kovalchik" <kovalchik@> wrote:
            > >
            > > I saw this a few days ago as well. Didn't think about applying it to
            > > Taffy though. Nice thinking!
            > >
            > > What's really interesting to me is that (on my machine) simply running
            > > the for loop in reverse yields at least double the speed across all
            > > tests in all browsers. Looks like it could be an easy way to speed up
            > > Taffy.
            > >
            > > I plugged reverse for loops into my copy of Taffy, ran the included
            > > speed test on a DB of 5000 records and ended up with the following:
            > >
            > > Create and Fill Taffy - 7% speed increase
            > > Do 80% record remove via lookup - 32% speed increase
            > > Do a forEach Update - 2% speed decrease
            > > Find Every Record - 28% speed increase
            > > Find Record 900 - 2% speed decrease
            > > Sort by Value Desc - 3% speed increase
            > >
            > > Then I did the same thing with a DB of 1000:
            > >
            > > Create and Fill Taffy - 4% speed increase
            > > Do 80% record remove via lookup - 25% speed increase
            > > Do a forEach Update - 0.5% speed increase
            > > Find Every Record - 26% speed increase
            > > Find Record 900 - 5% speed increase
            > > Sort by Value Desc - 7% speed increase
            > >
            > >
            > > Accounting for general margin of error, the 80% remove and finding
            every
            > > record gained a lot from this quick change. I was sort of
            surprised that
            > > finding a single record didn't receive any speed bumps, but I haven't
            > > had time to really look into that. Also, this test was using
            version 1.4
            > > originally. I changed the version of Taffy it was using, but
            didn't look
            > > at the syntax of the tests, so there might be some discrepancies
            I'm not
            > > aware of.
            > >
            > > At any rate, it does show that with a bit of testing, using a reverse
            > > for loop could garner some fairly significant speed gains with minimal
            > > changing of the current code base.
            > >
            > >
            > > --- In taffydb@yahoogroups.com, "berg.matt" <berg.matt@> wrote:
            > > >
            > > > Pretty interesting, especially if it can help improve speed.
            > > >
            > > > http://blogs.sun.com/greimer/resource/loop-test.html
            > > >
            > >
            >
          • berg.matt
            True, according to the tests from that site, the reverse while loop is the best performer. Sounds like a good fit for 1.7. Speed is always good. Matt ...
            Message 5 of 5 , Jul 31, 2008
            • 0 Attachment
              True, according to the tests from that site, the reverse while loop is
              the best performer. Sounds like a good fit for 1.7. Speed is always
              good.

              Matt

              --- In taffydb@yahoogroups.com, "tacoman_cool" <ian@...> wrote:
              >
              > Thanks Matt and Darren. Very cool information.
              >
              > By and large I've gotten the best result from this loop:
              >
              > var i = arr.length; while (i--) { }
              >
              > That should work for most of the loops if adopted. Any thoughts on
              > this vs the reverse for loops? Should we adopt it in 1.7?
              >
              > --- In taffydb@yahoogroups.com, "berg.matt" <berg.matt@> wrote:
              > >
              > > Thanks for running those tests so quickly. Pretty interesting
              results.
              > >
              > > Matt
              > >
              > > --- In taffydb@yahoogroups.com, "darren_kovalchik" <kovalchik@> wrote:
              > > >
              > > > I saw this a few days ago as well. Didn't think about applying it to
              > > > Taffy though. Nice thinking!
              > > >
              > > > What's really interesting to me is that (on my machine) simply
              running
              > > > the for loop in reverse yields at least double the speed across all
              > > > tests in all browsers. Looks like it could be an easy way to
              speed up
              > > > Taffy.
              > > >
              > > > I plugged reverse for loops into my copy of Taffy, ran the included
              > > > speed test on a DB of 5000 records and ended up with the following:
              > > >
              > > > Create and Fill Taffy - 7% speed increase
              > > > Do 80% record remove via lookup - 32% speed increase
              > > > Do a forEach Update - 2% speed decrease
              > > > Find Every Record - 28% speed increase
              > > > Find Record 900 - 2% speed decrease
              > > > Sort by Value Desc - 3% speed increase
              > > >
              > > > Then I did the same thing with a DB of 1000:
              > > >
              > > > Create and Fill Taffy - 4% speed increase
              > > > Do 80% record remove via lookup - 25% speed increase
              > > > Do a forEach Update - 0.5% speed increase
              > > > Find Every Record - 26% speed increase
              > > > Find Record 900 - 5% speed increase
              > > > Sort by Value Desc - 7% speed increase
              > > >
              > > >
              > > > Accounting for general margin of error, the 80% remove and finding
              > every
              > > > record gained a lot from this quick change. I was sort of
              > surprised that
              > > > finding a single record didn't receive any speed bumps, but I
              haven't
              > > > had time to really look into that. Also, this test was using
              > version 1.4
              > > > originally. I changed the version of Taffy it was using, but
              > didn't look
              > > > at the syntax of the tests, so there might be some discrepancies
              > I'm not
              > > > aware of.
              > > >
              > > > At any rate, it does show that with a bit of testing, using a
              reverse
              > > > for loop could garner some fairly significant speed gains with
              minimal
              > > > changing of the current code base.
              > > >
              > > >
              > > > --- In taffydb@yahoogroups.com, "berg.matt" <berg.matt@> wrote:
              > > > >
              > > > > Pretty interesting, especially if it can help improve speed.
              > > > >
              > > > > http://blogs.sun.com/greimer/resource/loop-test.html
              > > > >
              > > >
              > >
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.