patchBattle for Wesnoth - Patches: patch #3236, Improvement of...

Show feedback again

patch #3236: Improvement of "get_adjacent_tiles" by reducing redundant code.

Submitted by:  ptalbot <trademark>
Submitted on:  Tue 03 Apr 2012 09:06:16 PM UTC  
Priority: 5 - NormalStatus: In Progress
Privacy: PublicAssigned to: Iurii Chernyi <crab>
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Sat 07 Apr 2012 09:02:17 AM UTC, comment #4:

As I said on IRC, I didn't used any flags. With O2 option, there is a difference of 200ms instead of 1sec and with O3 option, there is no difference at all (3ms for all).

ptalbot <trademark>
Sat 07 Apr 2012 07:30:45 AM UTC, comment #3:

I like the `tricks' you used in your patch and your benchmark looks nice. Could you paste the compilation flags you used for your benchmark. (I'm somewhat surprised by the differences, I would expect the compiler use the same tricks in its object code.)

Mark de Wever <mordante>
Project Member
Sat 07 Apr 2012 06:49:23 AM UTC, comment #2:

Result of my tests for 100 millions calls:

Original function:

real 0m5.171s
user 0m5.164s
sys 0m0.004s

My first patch:

real 0m6.018s
user 0m6.008s
sys 0m0.012s

My second patch:

real 0m4.166s
user 0m4.164s
sys 0m0.000s

Everything is said, static array are slowly.

(file #15529, file #15530)

ptalbot <trademark>
Fri 06 Apr 2012 10:15:20 PM UTC, comment #1:

hello, for this code, the biggest concern is speed. can you test what is faster - your approach or previous approach, using some kind of microbenchmark?

(and don't forget to list this patch at your gsoc page, even if it's not yet committed)

Iurii Chernyi <crab>
Project MemberIn charge of this item.
Tue 03 Apr 2012 09:06:16 PM UTC, original submission:

It uses static const int array to loop over different adjacent position of a tile.

ptalbot <trademark>


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #15529:  get_adjacent_tiles.patch added by trademark (1kB - text/x-patch - The patch improve the performances by one second on a test-set of 100 millions calls. The test file is joined.)
file #15530:  test_map_location.cpp added by trademark (2kB - text/x-c++src - The patch improve the performances by one second on a test-set of 100 millions calls. The test file is joined.)
file #15511:  patch.patch added by trademark (1kB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by mordante (Posted a comment)
  • -unavailable- added by crab (Updated the item)
  • -unavailable- added by trademark (Submitted the item)
  • -unavailable- added by trademark

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 07 Apr 2012 06:49:23 AM UTCtrademarkAttached File-=>Added get_adjacent_tiles.patch, #15529
      Attached File-=>Added test_map_location.cpp, #15530
    Tue 03 Apr 2012 09:11:41 PM UTCcrabStatusNone=>In Progress
      Assigned toNone=>crab
    Tue 03 Apr 2012 09:06:16 PM UTCtrademarkAttached File-=>Added patch.patch, #15511
      Carbon-Copy-=>Added trademark
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup