I’m kind of curious what happens if you use file_get_contents to mmap the data, then do $index = 0 , and loop on $index = strpos($data, ";", $index) followed by strpos($data, "\n", $index) in a loop until it fails. I don’t have a PHP environment, or I think I’d try it….
Welp, that doesn’t work. file_get_contents mmaps the file (apparently) but copies the entire thing into an allocated string. So, it doesn’t create a virtual string or something like I had hoped.
Interesting that it uses -Os. I thought it only did optimization for binary size but seems there’s quite a big
intersection between O2 and Os.
-Os Optimize for size. -Os enables all -O2 optimizations except those that often increase code size:
-falign-functions -falign-jumps -falign-labels -falign-loops -fprefetch-loop-arrays -freorder-blocks-algorithm=stc
It also enables -finline-functions, causes the compiler to tune for code size rather than execution speed, and performs further optimizations designed to reduce code size.
It’s actually a fairly impressive result from PHP!
(Read the article :)
Much slower than Java, but getting close to only one order of magnitude difference.
I’m kind of curious what happens if you use
file_get_contentsto mmap the data, then do$index = 0, and loop on$index = strpos($data, ";", $index)followed bystrpos($data, "\n", $index)in a loop until it fails. I don’t have a PHP environment, or I think I’d try it….Welp, that doesn’t work.
file_get_contentsmmaps the file (apparently) but copies the entire thing into an allocated string. So, it doesn’t create a virtual string or something like I had hoped.Interesting that it uses
-Os. I thought it only did optimization for binary size but seems there’s quite a big intersection between O2 and Os.from man gcc