In order to estimate the time it takes to load an image in various ways I did the following test on my MacBook pro.
I wrote a dummy assembler file with 5 MB worth of code (which is about the size of Tachyon's machine code right now). It contains lines like:
.text .globl _codestart .globl _codeend _codestart: movq $123,%rax .byte 0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3 .byte 0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3 .byte 0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3
... ;; about 700,000 lines of the same here
_codeend:
This file takes 2.6 seconds to assemble using the GNU assembler, which is reasonable.
I linked the resulting object file with a main program in 2 variants:
- main just calls codestart and terminates (direct embedded code) - main allocates a 5 MB machine code block, and copies the code from codestart to codeend to the block (copied embedded code)
Finally, I also have a minimal C program which allocates a 5 MB machine code block, and reads a 5 MB binary file to the block using the Unix open and read functions (file code).
Here are the running times in seconds (after a few dry runs):
direct embedded code 0.003 copied embedded code 0.016 file code 0.009
The run time advantage of the first method is pretty clear. The startup is 3 to 5 times faster than the other methods.
So lets aim to implement that. As I said, the startup time is really important for some applications (remember what Andreas said about Firefox... one of the reasons it is not implemented more in JS is that the startup time is currently too large).
Marc