Interrupt driven compiling

IanMc

Well-Known Member
Licensed User
Longtime User
You know how you can do Alt 3 and the compilation process will take place in the background like some crazy kind of voodoo magic :D

Wouldn't it be spiffing if that process took place automatically then depending on whether you'd changed anything since the last time it took place, when you hit the compile button the compiler might poke it's tongue out at you and shout AHA! I've already done that bit so all I have to do now is install the .apk over to the device! AHA!

This is the running comentary on a compile:
B4X:
Parsing code.                           0.01
Compiling code.                         0.09
   
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.                 0.01
Generating R file.                      0.98
Compiling generated Java code.          1.79
Convert byte code - optimized dex.      4.38
   Optimized dexer failed. Switching to Standard dexer.
Packaging files.                        0.94
Copying libraries resources             0.01
Signing package file (private key)      0.70
ZipAlign file.                          0.10
Installing file to device.              4.05
   Device serial: 0123456789ABCDEF
Completed successfully.
I presume the numbers are times in seconds.milliseconds ?
Hmmm... interesting serial my device has :)
What! 4.38 seconds to convert byte code and optimize the dex?! (I have absolutely no idea what any of that means but don't I sound smart when you read this?)
Doh! Optimized dexer failed, oh darn.

Also I'd like to see some extra processes in there like:
B4X:
Making Tea     1.35
Massaging feet     4.68
Tidying room     8.71

:sign0188:
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I presume the numbers are times in seconds.milliseconds ?
That is correct.

What! 4.38 seconds to convert byte code and optimize the dex?! (I have absolutely no idea what any of that means but don't I sound smart when you read this?)
Doh! Optimized dexer failed, oh darn.
Regular Java applications are saved as java byte code. The JVM (Java Virtual Machine) executes this byte code. Android applications are saved in a different format named DEX (Dalvik Executable). The dexer step takes the Java compiler output (java byte code) and converts it to dex format.

The optimized dexer is a special version of the standard dexer which does most of the job in the background before you start to compile.

Do you always see this message?
Optimized dexer failed. Switching to Standard dexer.
 

IanMc

Well-Known Member
Licensed User
Longtime User
Do you always see this message?
Nope, this is the compile for my big app soon to be released :)
B4X:
Parsing code.                           0.25
Compiling code.                         1.17
   
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.                 0.13
Generating R file.                      2.11
Compiling generated Java code.          3.14
Convert byte code - optimized dex.      2.23
Packaging files.                        4.38
Copying libraries resources             0.17
   Found 2 resource files.
Signing package file (private key)      0.95
ZipAlign file.                          0.31
Installing file to device.              6.67
   Device serial: 0123456789ABCDEF
Completed successfully.

Same Device serial but I am using a rather unusual device (HTC HD2 with MIUI ROM)

This is the compile from that simple test app that I got the fail from:
B4X:
Parsing code.                           0.02
Compiling code.                         0.08
   
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.                 0.02
Generating R file.                      0.78
Compiling generated Java code.          1.52
Convert byte code - optimized dex.      0.67
Packaging files.                        0.88
Copying libraries resources             0.00
Signing package file (private key)      0.61
ZipAlign file.                          0.06
Installing file to device.              3.13
   Device serial: 0123456789ABCDEF
Completed successfully.
Working fine now.
I'm using the Beta 2.50 of B4A
 

IanMc

Well-Known Member
Licensed User
Longtime User
Further thoughts

About my 'interrupt driven compiling' idea.

You could make the algorithm quite sophisticated.

Firstly you'd only have it active when the user was actually using the B4A IDE so only when it was foremost although you might do the process once when the IDE no-longer held the focus, then you'd have a timer and a 'something changed' variable.

If IDE = OnTop And OptimumTimeToActionForThisUser And UserChanges > 5 And ItsNotRaining And TheSunsOut Then

The OptimumTimeToActionForThisUser could be an Int representing milliseconds and if we constantly keep having to restart the process because the user is making changes then we can increase this then decrease it again when the user slows down making changes etc.

Then when we think its a good time we can do:

That bit: Parsing code. 0.25
And sneek that bit in :Compiling code. 1.17

And this bit: ObfuscatorMap.txt file created in Objects folder.

We still ok? The user hasn't pressed anything and we're still on top etc. ?

Ok, then do this bit: Compiling layouts code. 0.13
And this bit: Generating R file. 2.11

What about now? We ok still? Can we compute the likelihood of having a few seconds free without the user doing anything here? Ok? good to go? then:

Ok, do this bit: Compiling generated Java code. 3.14

Convert byte code - optimized dex. 2.23
etc. Packaging files. 4.38
etc. Copying libraries resources 0.17
etc. Signing package file (private key) 0.95
etc. ZipAlign file. 0.31

Then the user presses the compile button and we've just shaved about 15 seconds off the compile process!!!!
 
Last edited:
Top