|
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!
Conclusion, C# I/O blows PHP by a factor of 4096!
|
|
|
|
|
Don't forget the PHP version is reading the file in binary and the C# version is converting the binary stream into Unicode characters.
|
|
|
|
|
It is years since I last heard it: "First, there are lies. Then there are d**m lies. And then comes benchmarks."
But why did that old truth come to mind now?
|
|
|
|
|
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 linq collection.Where(x=>x == '1') was always the slowest code.
1) Counting with a foreach 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 normal for took about the same amount of time as the foreach 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
modified 20-Mar-22 8:57am.
|
|
|
|
|
We’re in for a treat today, as NASA plans to roll out its much-anticipated Space Launch System rocket in anticipation of the wet dress rehearsal and Artemis 1 trip to the Moon and back. Someone's got rocket envy
|
|
|
|
|
Change your router's default password and make it a strong one, warns Microsoft. Nasty, tricksy bots! We hates them!
|
|
|
|
|
Improving jobs satisfaction among software teams means focusing on work-life balance, flexibility and – you guessed it – pay. "To crush your enemies, see them driven before you, and to hear the lamentation of their women!" And a ping pong table.
(and one more thing)
|
|
|
|
|
The company set out new programs for partners that entice them to sell services across six distinct cloud products and service areas. Someone has their head in the clouds
I'm assuming there might be a few members who work for partner firms
|
|
|
|
|
Windows admins were hit today by a wave of Microsoft Defender for Endpoint false positives where Office updates were tagged as malicious in alerts pointing to ransomware behavior detected on their systems. But is it wrong?
|
|
|
|
|
Every Office update is malicious. They always break certain add-ins I have to deal with.
|
|
|
|
|
I always get a chuckle out of AV updates that start flagging common applications, including themselves as malware.
|
|
|
|
|
Tech execs could be jailed if they fail to respond to requests for information from newly-empowered regulator Ofcom “in an accurate and timely manner,” according to the bill. Hopefully coming soon: Same, but for politicians
A boy can dream, can't he?
|
|
|
|
|
|
Who needs the Babylon Bee?!
|
|
|
|
|
UK parliament still hasn't moved on from "Babbage, if you put into the machine wrong figures, will the right answers come out?"
GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
My father was Swedish and once told a guy at work that he still thought in Swedish when doing mental arithmetic. Which prompted the question, "But do you get the same answer?"
|
|
|
|
|
How can anyone be sure that tolf and twelve are, effectively, the same quantity?
GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
Bex is part of the Kaleido project, stemming from Kawasaki’s Robust Humanoid Platform. It is a quadruped robot inspired by the wild goat ibex in the mountainous regions of Africa and Eurasia. Yippie-yi-o Yippie-yi-yay Goat riders in ... the sky
|
|
|
|
|
Clearly not ready to reseed a post-apocalyptic earth, but maybe it's on the Horizon?
|
|
|
|
|
The second preview of .NET 7 includes enhancements to RegEx source generators, progress moving NativeAOT from experimental status into the runtime, and a major set of improvements to the “dotnet new” CLI experience. So you can enjoy that new compiler smell
Many apologies for missing this a couple of days ago. Those responsible have been bolted to their machine to avoid missing in the future.
|
|
|
|
|
As you make code changes, Live Unit Testing detects what tests are impacted and runs them in the background. That should kill VS performance nicely
|
|
|
|
|
And when it finds a bug, delivers a jolt through the electrodes implanted in your...
|
|
|
|
|
Oscar Goldman Quote: We can rebuild him it. We have the technology. We can make him it better than he was. Better, stronger, faster. DA DA DA DA DA DA DA DA
DA DA DA DA DA DA DA DA
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
The first Bug Bash of 2022 is now live, and you can participate in helping Microsoft polish Windows 11 before its first feature update arrives. Because all their testers are busy polishing icons
|
|
|
|
|
I can think of something else that a colloquial phrase says gets polished.
|
|
|
|