Earlier quoted context omitted.
How would you optimize sum.c to be faster?
GCC with -O3 might try to unroll this loop into a single constant. O(0) is pretty fast.
How much your computer can do in a second
11–20 of 244 posts
Re: How much your computer can do in a second
#12For instance the question about web requests to google. Depending on your internet connection you've got more than a order of magnitude difference in the outcome.
In the question about SSD performance the only hint we have is that the computer has "an SSD", 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.
The question about JSON/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?
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's going to be at least an order of magnitude slower.
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/Disk is doing. Questions that can be reduced to "what language is this python library written in" aren't as insightful.
Re: How much your computer can do in a second
#13Computers are fast, but not if all that speed is wasted.
A recent related article: https://news.ycombinator.com/item?id=13940014
Re: How much your computer can do in a second
#14Earlier quoted context omitted.
GCC as expected, O>2 sub rsp, 8 mov rdi, QWORD PTR [rsi+8] mov edx, 10 xor esi, esi call strtol Interestingly enough it does not elide the entire function body.
How do you get objdump -S to print out non AT&T syntax? My output looked like this: 000000000400400 : 400400: 48 83 ec 08 sub $0x8,%rsp 400404: 48 8b 7e 08 mov 0x8(%rsi),%rdi 400408: ba 0a 00 00 00 mov $0xa,%edx 40040d: 31 f6 xor %esi,%esi 40040f: e8 dc ff ff ff callq 4003f0 400414: 31 c0 xor %eax,%eax 400416: 48 83 c4 08 add $0x8,%rsp 40041a: c3 retq 40041b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) Which I'm not a fan o…
Re: How much your computer can do in a second
#15Earlier quoted context omitted.
GCC as expected, O>2 sub rsp, 8 mov rdi, QWORD PTR [rsi+8] mov edx, 10 xor esi, esi call strtol Interestingly enough it does not elide the entire function body.
How do you get objdump -S to print out non AT&T syntax? My output looked like this: 000000000400400 : 400400: 48 83 ec 08 sub $0x8,%rsp 400404: 48 8b 7e 08 mov 0x8(%rsi),%rdi 400408: ba 0a 00 00 00 mov $0xa,%edx 40040d: 31 f6 xor %esi,%esi 40040f: e8 dc ff ff ff callq 4003f0 400414: 31 c0 xor %eax,%eax 400416: 48 83 c4 08 add $0x8,%rsp 40041a: c3 retq 40041b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) Which I'm not a fan o…
Re: How much your computer can do in a second
#16Re: How much your computer can do in a second
#17Alternatively, this could be titled "do you know how much your computer could do in a second but isn't because of bad design choices, overengineered bloated systems, and dogmatic adherence to the 'premature optimisation' myth?" Computers are fast, but not if all that speed is wasted. A recent related article: https://news.ycombinator.com/item?id=13940014
Personally I always feel weird booting up old boxes (say old = Pentium 2) and realizing how much the whole platform could do. It also felt quite sufficient in terms of UX and presentation.
That's odd because, everybody (I assume) feels how quickly we feel our newest gear gets slow, and how a new generation improves speed. But when I pop a very old system I don't feel slowed down much. It's just of a lesser resolution (hi res images, sound, videos); which for my needs doesn't really matter.
Re: How much your computer can do in a second
#18Pretty cool, but a number of the questions are totally unknowable. For instance the question about web requests to google. Depending on your internet connection you've got more than a order of magnitude difference in the outcome. In the question about SSD performance the only hint we have is that the computer has "an SSD", but a modern PCIe SSD like in the new Macbook pro is over 10 times faster than the SSDs we got…
You noticed here that it is also hard to tell in a high abstraction layer which operations might be fast and which may be slow.
Often this is even found in seemingly simple places, e.g. traversing a List in Java can have vastly different performance characteristics (LinkedList vs. ArrayList).
Re: How much your computer can do in a second
#19https://gist.github.com/jboner/2841832
Edit: Just realized halfway through that there's already a link to this from their page!
Re: How much your computer can do in a second
#20Alternatively, this could be titled "do you know how much your computer could do in a second but isn't because of bad design choices, overengineered bloated systems, and dogmatic adherence to the 'premature optimisation' myth?" Computers are fast, but not if all that speed is wasted. A recent related article: https://news.ycombinator.com/item?id=13940014
The market is wasteful. Lots of things are subpar because of the competition requiring adhoc solutions pushed to market, then becoming standard, so on and so forth. You can blame the game or not. At least if there was some acknowledgement of that process and a little cleanup time to spread good ideas and good fix ... Personally I always feel weird booting up old boxes (say old = Pentium 2) and realizing how much the…