Timeline for Parser written in PHP is 5.6x faster than the same C++ program in a similar test (g++ 4.8.5)
Current License: CC BY-SA 4.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 2, 2020 at 15:57 | history | edited | Your Common Sense | CC BY-SA 4.0 |
added 546 characters in body
|
Aug 2, 2020 at 12:19 | history | undeleted | Your Common Sense | ||
Aug 2, 2020 at 12:19 | history | edited | Your Common Sense | CC BY-SA 4.0 |
deleted 458 characters in body
|
Aug 2, 2020 at 11:11 | history | deleted | Your Common Sense | via Vote | |
Aug 2, 2020 at 10:25 | comment | added | Your Common Sense | Well, surely we can buffer at the expense of memory, but the code in the OP doesn't buffer either. It seems fgetcsv is incredibly slow, like 40 times slower than fgets/explode. fputcsv is better but still several times slower than join/fwrite | |
Aug 2, 2020 at 10:05 | comment | added | aki | stackoverflow.com/questions/2749441/… apparently OP had already used a fast way to read files in php. | |
Aug 2, 2020 at 9:32 | comment | added | aki |
If I read it correctly, (php noob here) it calls fgetcsv a million times and fputcsv 50k times. That will be very poor even in C++ due to system calls. can php buffer file contents ?
|
|
Aug 2, 2020 at 8:58 | comment | added | Your Common Sense | Man, it takes ages for my version to perform. | |
Aug 2, 2020 at 8:49 | history | edited | Your Common Sense | CC BY-SA 4.0 |
added 86 characters in body
|
Aug 2, 2020 at 8:28 | comment | added | aki |
Several problems: 1 It gives a syntax error since it has two opening braces after while(..){{ .. } 2 It writes nothing to the outFile , it remains zero bytes. 3 It takes 9 seconds to complete (compare it with the timings in my answer.) // Run this quick script to make a file ideone.com/gkmUUN and run your program to test it. command I used (if it matters) gdate +%s.%3N && php parser.php && gdate +%s.%3N
|
|
Aug 2, 2020 at 7:17 | history | edited | Your Common Sense | CC BY-SA 4.0 |
added 221 characters in body
|
Aug 2, 2020 at 7:11 | history | answered | Your Common Sense | CC BY-SA 4.0 |