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.

Why is printing “B” dramatically slower than printing “#”?

260 pointsby marcopolisover 11 years ago

15 comments

codereflectionover 11 years ago
This post highlights the issue with overly zealous mods on SO who marked the question as off topic. Nothing about this is off topic, and it turned out to be very interesting answer.
评论 #7294438 未加载
评论 #7294712 未加载
评论 #7296694 未加载
评论 #7294502 未加载
评论 #7294695 未加载
评论 #7294518 未加载
评论 #7297229 未加载
koenigdavidmjover 11 years ago
Entirely unrelated, but this headline made me notice that Chrome finally supports entering " in the find-in-page box and having it match so-called smart quotes.
评论 #7294435 未加载
评论 #7294529 未加载
评论 #7295375 未加载
评论 #7294370 未加载
cbsmithover 11 years ago
Oh good lord. This question is more about properly isolating your tests (i.e. writing the characters to &#x2F;dev&#x2F;null and getting rid of the &quot;random&quot; call) and properly profiling code (which would show high CPU consumption on the <i>console</i>, not the program writing to stdout) more than anything &quot;tricky&quot; about performance.
评论 #7294729 未加载
gavinpcover 11 years ago
Hilarious! I never see confirmation bias in action so much as when SO answers get posted on HN:<p>&quot;See, this is exactly what&#x27;s wrong with SO.&quot;<p>&quot;Really? Because it seems like a perfect example of why SO works perfectly.&quot;<p>Of course, I find I am increasingly disposed to read the comments that way...
chris_wotover 11 years ago
Just shows that seemingly obscure questions can often show that there are underlying things you need to pay attention to!
jrockwayover 11 years ago
This, incidentally, is a good user interface study. The terminal emulator works so well that most users don&#x27;t even know it&#x27;s there. But it&#x27;s actually a pretty complex piece of software.
tedchsover 11 years ago
Apparently the answer had to do with terminal word-wrapping. A good test would be to write the output to a file instead of the terminal and compare the difference in timing.
评论 #7297355 未加载
Ellipsis753over 11 years ago
I find it amazing that they actually got the correct answer. How on earth did they guess that?
评论 #7294558 未加载
评论 #7295318 未加载
ansibleover 11 years ago
There are terminals that do word wrapping?<p>Well, I shouldn&#x27;t be surprised... There are people who try to code with a proportional font too, so I guess anything is possible, though it may not make sense to me.
评论 #7294850 未加载
prewettover 11 years ago
I&#x27;m actually a little surprised that the answer wasn&#x27;t something along the lines of &quot;# is simple straight lines, while B requires a bunch of Bezier splines for TrueType to render.&quot; I guess the graphics cards must accelerate that or something. I&#x27;m surprised that line-breaking algorithms take that long.
评论 #7296206 未加载
评论 #7298043 未加载
delinkaover 11 years ago
1) Asking about running times on code with calls to an RNG ... remove the randomness first, profile repeatedly<p>2) Outputting to STDOUT can have some serious overhead depending on where you&#x27;re actually rendering the text-- textview inside your IDE? Crazy, off-the-wall terminals? Let&#x27;s dump this to a file and see how long it takes
estover 11 years ago
reminds me of worldwide newbie python Unicode rage. The culprit was Windows&#x27;s cmd.exe and Linux&#x27;s LC_ALL
fexlover 11 years ago
I bet if he had redirected the output to &#x2F;dev&#x2F;null it wouldn&#x27;t be slower with &#x27;B&#x27;.
chjover 11 years ago
good detective work!
muroover 11 years ago
Printing random boobs is slow, okay.
评论 #7295164 未加载