TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How much your computer can do in a second

602 pointsby srirangrabout 8 years ago

32 comments

gizmoabout 8 years ago
Pretty cool, but a number of the questions are totally unknowable.<p>For instance the question about web requests to google. Depending on your internet connection you&#x27;ve got more than a order of magnitude difference in the outcome.<p>In the question about SSD performance the only hint we have is that the computer has &quot;an SSD&quot;, but a modern PCIe SSD like in the new Macbook pro is over 10 times faster than the SSDs we got just 5 years ago.<p>The question about JSON&#x2F;Msgpack parsing is just about the implementation. Is the python msgpack library a pure python library or is the work of the entire unpackb() call done in C?<p>The bcrypt question depends entirely on the number of rounds. The default happens to be 12. Had the default been 4 the answer would have been 1000 hashes a second instead of 3. Is the python md5 library written in C? If so, the program is indistinguishable from piping data to md5sum from bash. Otherwise it&#x27;s going to be at least an order of magnitude slower.<p>So I liked these exercises, but I liked the C questions best because there you can look at the code and figure out how much work the CPU&#x2F;Disk is doing. Questions that can be reduced to &quot;what language is this python library written in&quot; aren&#x27;t as insightful.
评论 #13961155 未加载
评论 #13961348 未加载
realoabout 8 years ago
Yes, modern computers are fast. How fast?<p>The speed of light is about 300,000 km&#x2F;s. That translates to roughly 1 ns per foot (yeah, I mix up my units... I&#x27;m Canadian...)<p>THUS, a computer with a clock speed of 2 GHz will be able to execute, on a single core&#x2F;thread, about 4 (four !) single-clock instructions between the moment photons leave your screen, and the moment they arrive into your eye 2 feet (roughly) later.<p>_That_ should give you an idea of how fast modern computers really are.<p>And I _still_ wait quite a bit when starting up Microsoft Word.
评论 #13962494 未加载
评论 #13961530 未加载
评论 #13961664 未加载
评论 #13964540 未加载
评论 #13961344 未加载
评论 #13962227 未加载
munificentabout 8 years ago
If, like me, you spend most of your time in high-level, garbage collected &quot;scripting&quot; languages, it&#x27;s really worth spending a little time writing a few simple C applications from scratch. It is <i>astonishing</i> how fast a computer is without the overhead most modern languages bring in.<p>That overhead adds tons of value, certainly. I still use higher level languages most of the time. But it&#x27;s useful to have a sense of how fast you <i>could</i> make some computation go if you really needed to.
评论 #13963497 未加载
评论 #13962670 未加载
评论 #13962750 未加载
评论 #13961956 未加载
评论 #13966056 未加载
userbinatorabout 8 years ago
Alternatively, this could be titled &quot;do you know how much your computer <i>could</i> do in a second but isn&#x27;t because of bad design choices, overengineered bloated systems, and dogmatic adherence to the &#x27;premature optimisation&#x27; myth?&quot;<p>Computers are fast, but not if all that speed is wasted.<p>A recent related article: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13940014" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13940014</a>
评论 #13961826 未加载
评论 #13961153 未加载
评论 #13961424 未加载
评论 #13961497 未加载
评论 #13963180 未加载
评论 #13967303 未加载
评论 #13966417 未加载
评论 #13968604 未加载
评论 #13967552 未加载
评论 #13963501 未加载
评论 #13961778 未加载
chacham15about 8 years ago
Be careful what conclusions you attempt to draw from examples when you arent sure what exactly is happening. These examples are actually very wrong and misleading.<p>Take for example, the first code snippet about how many loops you can run in 1 second. The OP fails to realize that since the loop isnt producing anything which gets actually used, the compiler is free to optimize it out. You can see that thats exactly what it does here: <a href="https:&#x2F;&#x2F;godbolt.org&#x2F;g&#x2F;NWa5yZ" rel="nofollow">https:&#x2F;&#x2F;godbolt.org&#x2F;g&#x2F;NWa5yZ</a> All it does is call strtol and then exits. It isnt even running a loop.
评论 #13962541 未加载
评论 #13962526 未加载
评论 #13962467 未加载
评论 #13962486 未加载
评论 #13962403 未加载
评论 #13962499 未加载
评论 #13962498 未加载
dom0about 8 years ago
More impressively, sum.c could go likely an order of magnitude or so faster, when optimized.<p>&gt; Friends who do high performance networking say it&#x27;s possible to get network roundtrips of 250ns (!!!),<p>Well stuff like Infiniband is less network, and more similar to a bus (e.g. RDMA, atomic ops like fetch-and-add or CAS).<p>&gt; write_to_memory.py<p>Is also interesting because this is dominated by inefficiencies in the API and implementation and not actually limited by the memory subsystem.<p>&gt; msgpack_parse.py<p>Again, a large chunk goes into inefficiencies, not so much the actual work. This is a common pattern in highly abstracted software. msgpack-c mostly works at &gt;200 MB&#x2F;s or so (obviously a lot faster if you have lots of RAWs or STRs and little structure). Funnily enough, if you link against it and traverse stuff, then a lot of time is spent doing traversals, and not the actual unpacking (in some analysis I&#x27;ve seen a ~1&#x2F;3 - 2&#x2F;3 split). So the cost of abstraction also bites here.<p>If you toy around with ZeroMQ you can see that you&#x27;ll be able to send around 3 million msg&#x2F;s between threads (PUSH&#x2F;PULL) from C or C++, around 300k using pyzmq (this factor 10 is sometimes called &quot;interpreter tax&quot;), but only around 7000 or so if you try to send Python objects using send_pyobj (which uses Pickle). That&#x27;s a factor 430.
评论 #13960977 未加载
Eliezerabout 8 years ago
What an excellent teaching pattern - you&#x27;re far more likely to remember what you learned if you first stop to think and record your own guess, and this is excellent UI and UX for doing that routinely and inline.
评论 #13963328 未加载
baneabout 8 years ago
This is awesome. The real lesson here is, when you make a thing, compare its performance to these kinds of expected numbers and if you&#x27;re not within the same order of magnitude speedwise, you&#x27;ve probably screwed up somewhere.<p>My favorite writeups are the ones that gloat about achieving hundreds of pages served per second per server. That&#x27;s terrible, and nobody today even understands that.
alkonautabout 8 years ago
Don&#x27;t some of these examples run in O(1) time because the value in the loop isn&#x27;t used? E.g in the first example 0 is returned instead of the sum.<p>Obviously we are talking about real world c compilers with real world optimizations so presumably we&#x27;d have to also consider whether the loop is executed at all?
paulsutterabout 8 years ago
That&#x27;s nothing. Here&#x27;s code that does 77GFLOPS on a single Broadwell x86 core. Yes that 77 billion opertaions per second.<p><a href="http:&#x2F;&#x2F;pastebin.com&#x2F;hPayhGXP" rel="nofollow">http:&#x2F;&#x2F;pastebin.com&#x2F;hPayhGXP</a>
评论 #13964014 未加载
asrpabout 8 years ago
This reminds me of &quot;Latency Numbers Every Programmer Should Know&quot;<p><a href="https:&#x2F;&#x2F;gist.github.com&#x2F;jboner&#x2F;2841832" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;jboner&#x2F;2841832</a><p>Edit: Just realized halfway through that there&#x27;s already a link to this from their page!
gburtabout 8 years ago
The `bcrypt` question seems out-of-place. It has a configurable cost parameter, so almost any of the answers is correct.
bchabout 8 years ago
Hard to believe there are 124 comments here and nobody has brought up Grace Hopper&#x27;s talk[0][1] yet. With good humour she gives a example of what various devices&#x27; latency are, and a simple tool to comprehend the cost and orders of magnitude.<p><pre><code> [0] short - https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=JEpsKnWZrJ8 [1] long - https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ZR0ujwlvbkQ</code></pre>
gibsjoseabout 8 years ago
I&#x27;m curious to see the data collected on guesses. Some were quite difficult to guess, like hashes per second with bcrypt not knowing the cost factor, but I guess we can assume some sane default.<p>I would have really liked to see all these numbers in C, and other languages for that matter. Perhaps add a dropdown box to select the language from a handful of options?
tomc1985about 8 years ago
One second on what?<p>A Core i7? A raspberry Pi? A weird octo-core dual-speed ODROID? An old i915-based Celeron? My cell phone? An arduino?<p>&quot;Your computer&quot; has meant all the above to me, just in the last few weeks. The author&#x27;s disinclination to describe the kind of hardware this code is running on -- other than &quot;a new laptop&quot; -- strikes me as kind of odd.
alcuadradoabout 8 years ago
This reminds me to this email from LuaJIT&#x27;s list:<p>Computers are fast, or, a moment of appreciation for LuaJIT <a href="https:&#x2F;&#x2F;groups.google.com&#x2F;forum&#x2F;#!msg&#x2F;snabb-devel&#x2F;otVxZOj9dLA&#x2F;rgCojUohBGMJ" rel="nofollow">https:&#x2F;&#x2F;groups.google.com&#x2F;forum&#x2F;#!msg&#x2F;snabb-devel&#x2F;otVxZOj9dL...</a>
norswapabout 8 years ago
Brilliant! I&#x27;d like to see those numbers summarized somewhere though, a bit like the latency numbers every programmer should know: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;jboner&#x2F;2841832" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;jboner&#x2F;2841832</a> (visual: <a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;k0t1e.png" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;k0t1e.png</a>)
partycoderabout 8 years ago
Computers are fast unless your algorithm is quadratic or worse, then there&#x27;s no computer to help you.
Lxrabout 8 years ago
Why isn&#x27;t the first Python loop (that does nothing but pass) optimised away completely?
评论 #13965698 未加载
评论 #13961637 未加载
评论 #13961425 未加载
评论 #13962336 未加载
ge96about 8 years ago
I came across this &quot;article&quot;? before in the past, I feel like I remember it under a different title like &quot;language speed differences&quot; or something. Or maybe that&#x27;s another article by the same author&#x2F;site&#x2F;format.
srikuabout 8 years ago
The grep example should search for one character. Grep can skip bytes so that longer search strings are faster to search for. On my machine, I get from 22%-35% more time taken if I changed &quot;grep blah&quot; to &quot;grep b&quot;.
thomastjefferyabout 8 years ago
Or &quot;how fast can one of my 8 CPU cores run a for loop?&quot; To put that in perspective: all 8 cores together give me about 40gflops. I have 2 GPUs that each give me more than 5000gflops.
urzaabout 8 years ago
Anyone care to rewrite these into c#? I am really surprised how fast these python scripts are and I would like to see comparison with equivalent tasks in c# where it stands..
kobeyaabout 8 years ago
Was disappointed to find that nearly all the examples were Python and shell script. I&#x27;m not interested in knowing random trivia about how slow various interpreters are.
samirmabout 8 years ago
The last question seems really misleading. Most modern CPUs have a cache size of 8MB (max), yet the answer is &gt;300MB?
tim333about 8 years ago
Or running Windows Vista you can right click and display a menu in one second plus about 29 other seconds.
wtbobabout 8 years ago
Well, my computer won&#x27;t display an image apparently inserted with JavaScript, although it <i>could</i> if I wanted to grant execute privileges on it to computers-are-fast.github.io<p>Does anyone have a link to the image(s)?
评论 #13965127 未加载
brianwawokabout 8 years ago
&gt; GitHub Pages is temporarily down for maintenance.<p>Ironic?
ilakshabout 8 years ago
NVMe SSD can be up to 10X faster than SATA.
d--babout 8 years ago
or &quot;computers are fast, so we might just slow things down by using python for numerical calculations&quot;
joelthelionabout 8 years ago
This could make a pretty good hiring test. Not expecting perfect answers, but a rough correlation with the results, and some good explanations.
grepthisababout 8 years ago
Edit: I&#x27;m an idiot
评论 #13962301 未加载
评论 #13962349 未加载