HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

[tool] JassOptimizer

10-05-2010, 10:34 AM#1
Tot
Hell o, am back

thanks to conscription and the stupid bundeswehr-fuckers i had to make an involuntary pause in my mapping activities...

onTopic:
today i checked some of my maps and found lots of unperformant code, so i decided to write an optimizer for it and viola here it is.


requires microsoft .Net framework 3.5 or higher

usage:

quite simple
- get the executeable
- extract the "war3map.j" from your map or use another .j file
- execute it
- drop your beloved piece of code (.j-file)
- press enter
- wait some sec
- go to the displayed output-path and use the file with "_optimized.j"
- check the code again (if you don't trust me)
- name it "war3map.j" and place it in your map again

ATTENTION:
PLEASE FOR THE SAKE OF THE OLD GODS USE ONLY FILES W I T H O U T SYNTAX-ERRORS, otherwise the program will bug or crash

optimization-details:


- constant inlining
- removes unused globals
- removes unused functions (never call functions via ExecuteFunc(someFancyNonConstantVariable))
- removes stupid functions (like DoNothing or without code and no function-call in local-declaration)



if you wanna have the source, pm me...

changelog:


1.0.0.0: initial release



to do:


- find some way to reduce framework number (without causing random crashes)
- make the desobjusificator work
- add function inliner
- add some kind of syntax-check
- find a way to add it into jngp
- add detection of unreachable code (if false then, exitwhen true)
- add detection of critical errors(endless loops, ExecuteFunc + nonexistant function name, ...)
- precalculate constants

Attachment 49638
10-05-2010, 01:13 PM#2
DioD
post any code before and after optimization.

i suggest you to optimize code of any custom blizzard map, skibi for exs
10-05-2010, 01:57 PM#3
Tot
attached files in first post...
10-05-2010, 04:45 PM#4
DioD
your system mess with spaces, easy to detect on jasshelper__initstructs25167235

also constant inline failed for functions and basic mathematic operations.
10-05-2010, 06:17 PM#5
Tot
Quote:
Originally Posted by DioD
your system mess with spaces, easy to detect on jasshelper__initstructs25167235

can't follow you...plz explain further

Quote:
Originally Posted by DioD
also constant inline failed for functions and basic mathematic operations.

ähm yea, maybe i should mention that it does atm only inline constant GLOBALS with containing no function calls or other operations, cause in some cases the code would become slower when inlining these...
ex
Collapse JASS:
globals
constant real HardToCalc = SquareRoot(Cos(12)*Sin(32)*Atan(45)+I2R(R2I(Pow(Cos(18+Tan(8)),Atan2(6,13)))))

function Test takes real f returns nothing
local integer i=0
loop
exitwhen i>HardToCalc*f
set i=i+Atan2(HardToCalc,HardToCalc+1)
endloop
endfunction

i know it's a constructed and exaggerated example, but something like this can happen...therefore I'm searching a way to precalculate such constants...buggy atm
10-06-2010, 04:02 PM#6
DioD
its possible to calculate this inside optimizer (just include some limits, 2-3 levels of variables) and pass actual data into inline.
10-07-2010, 08:42 AM#7
Tot
Quote:
Originally Posted by DioD
its possible to calculate this inside optimizer (just include some limits, 2-3 levels of variables) and pass actual data into inline.

i know, that's what i'm trying to add in the next version...ufo it currently bugs heavyly or miscalculates (2+3*4 = 20 )

what's with the space-mess?
10-07-2010, 10:39 AM#8
DioD
your optimizer add spaces, i posted function name, check before and after.

to calculate properly you shoud sort actions by priority levels or hook into some other math library.
10-07-2010, 11:35 AM#9
Tot
Quote:
Originally Posted by DioD
your optimizer add spaces, i posted function name, check before and after.

yea...and where's the problem/bug?
10-08-2010, 03:40 AM#10
DioD
this is dead data, it shoud remove useless spaces not add em.
10-08-2010, 05:54 AM#11
Tot
Quote:
Originally Posted by DioD
this is dead data, it shoud remove useless spaces not add em.
you're right
10-10-2010, 06:39 PM#12
Troll-Brain
No offence and all, but does it more than wc3mapoptimizer ?
I suppose so, but could you detail the differences ?
12-12-2010, 05:24 PM#13
SanKakU
lol...when i want to remove empty spaces i do ctrl h and enter 4 spaces in top line, nothing in bottom line and hit all and bam, code optimized...well, at least primed for optimization. if your code adds those 4 spaces back everytime it's run...then it's trash.
03-02-2011, 10:17 AM#14
Bribe
Having spaces in your code does nothing at all in performance nor KB size.