Live data from Hacker News

4 billion if statements (2023)

andreasjhkarlsson.github.io

51–60 of 183 posts

Re: 4 billion if statements (2023)

#51

> I saw from the SSD was around 800 MB/s (which doesn’t really make sense as that should give execution speeds at 40+ seconds, but computers are magical so who knows what is going on). If anyone knows what’s actually going on, please do tell.

Presumably after the first run much or all of the program is paged into OS memory

Yes, or it was still in memory from writing.

The numbers match quite nicely. 40gb program size minus 32gb RAM is 8gb, divided by 800mb/s makes 10 seconds.

Re: 4 billion if statements (2023)

#55
post #41
post #8

Gemini took 4 seconds to answer this prompt: "Here is a number 4200020010101. Think deeply about it and tell me if it is not or or not even." So if you're concerned with privacy issues, you can run the assembly version proposed in the article locally and be well within the same order of performance. Let's thank the author of the article for providing a decent alternative to Google. ah, but the license is not that goo…

>Think deeply about it and tell me if it is not or or not even I think I just experienced a segfault

Why do they call it even when you of in the true number of out false odd the number?

Re: 4 billion if statements (2023)

#56

I have never seen anyone argue for a ‘switch’ version. switch (v) { case: 0,2,4,8,…: return EVEN; case: 1,3,5,7,…: return ODD; default: return IDK; } Slightly less code to generate.

you forgot the logic to strip the final digit and assign it to v. processing the whole number is absurd

I think the idea is to fill in the ellipses with even/odd numbers, up to 4B.

You know, to save the performance cost of processing the input as a string, and chomping off all but the last character.

Re: 4 billion if statements (2023)

#57
post #8

Gemini took 4 seconds to answer this prompt: "Here is a number 4200020010101. Think deeply about it and tell me if it is not or or not even." So if you're concerned with privacy issues, you can run the assembly version proposed in the article locally and be well within the same order of performance. Let's thank the author of the article for providing a decent alternative to Google. ah, but the license is not that goo…

> if it is not or or not even

Did you want to test the LLM's grammatical comprehension?

Re: 4 billion if statements (2023)

#59
A much cooler approach would have been to generate the ASM from the same program, rather than generate a file from python and load that file from C++. The multi-stage build and filesystem are completely unnecessary.

The technique actually has a lot of practical applications, so it's useful to have a C++ library that helps you with generating amd64 machine code.

Re: 4 billion if statements (2023)

#60

I have never seen anyone argue for a ‘switch’ version. switch (v) { case: 0,2,4,8,…: return EVEN; case: 1,3,5,7,…: return ODD; default: return IDK; } Slightly less code to generate.

you forgot the logic to strip the final digit and assign it to v. processing the whole number is absurd

Look at Mr. Rocket Scientist over here...
Post reply on HN