Yes, PHP is faster than C#
-
There’s something very common that all developers must do, and that is read files… we need to parse things, transform file formats, or whatever. So, let’s compare the two languages.
* for one highly contrived example
-
There’s something very common that all developers must do, and that is read files… we need to parse things, transform file formats, or whatever. So, let’s compare the two languages.
* for one highly contrived example
One badly written example *and* he turned off optimizations. The algorithms don't even match (apologies to the UK.)
-
There’s something very common that all developers must do, and that is read files… we need to parse things, transform file formats, or whatever. So, let’s compare the two languages.
* for one highly contrived example
well.. he read by chunk of 4096 byte buffer in PHP, and 1 byte at a time in C#, doing 4096 more I/O operation in C#, yet times are comparable! :O Conclusion, C# I/O blows PHP by a factor of 4096! :O
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
well.. he read by chunk of 4096 byte buffer in PHP, and 1 byte at a time in C#, doing 4096 more I/O operation in C#, yet times are comparable! :O Conclusion, C# I/O blows PHP by a factor of 4096! :O
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
There’s something very common that all developers must do, and that is read files… we need to parse things, transform file formats, or whatever. So, let’s compare the two languages.
* for one highly contrived example
-
There’s something very common that all developers must do, and that is read files… we need to parse things, transform file formats, or whatever. So, let’s compare the two languages.
* for one highly contrived example
I did a c# only test (running in VS 2017 in a Win7 VM). Omitting file reading time, and conversion to text (for the string counters, and conversion to a byte array for the stream counting), I only timed the actual time required to count the occurrences of '1'. I averaged three runs for each situation. 0) The chosen file was a paintshop pro image file that was 4,046,848 bytes large. 1) I wrote a string (and MemorySream) extension method for each of the three counting styles. 2) Each count run was executed three times per counting style, and the result was averaged. 3) The duration calculation only included the actual time it took to count the number of '1' characters in the string/stream. Any conversion code that was performed was not included i the duration calculation. I found that the reported durations were *all over the map*. For instance, counting as a string with a
.Where
call took from 44ms to 147ms. All counting styles exhibited this behavior. However, some general observations could be made: 0) Using some variation of linqcollection.Where(x=>x == '1')
was always the slowest code. 1) Counting with aforeach
loop was almost twice as fast for strings as using.Where
, but streams were only about 1/3 faster than their string counterparts. 2) Counting with a normalfor
took about the same amount of time as theforeach
code (the difference was +/- 2 ms. Again, the actual reported durations were all over the map, so mentioning them specifically would be kinda pointless. My considered opinion is that this article is just more bullshit from someone that tried to be a programmer and couldn't pull it off, so now he writes articles about programming, telling us (actual programmers) how we should do it.".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013