Live data from Hacker News

A Million Digits of Pi in 9 Lines of JavaScript

ajennings.net

81–86 of 86 posts

Re: A Million Digits of Pi in 9 Lines of JavaScript

#81

Earlier quoted context omitted.

Sure but one has 10x more digits than the other so takes a heck of a lot longer to convert and display the string for the same number of iterations. As a quick test of my theory the majority of the time is being spent trying to display the progress: - Default 100,000 = 58.276 - CSS display: none; = 22.359 - Display when done = 20.057

> Sure but one has 10x more digits than the other so takes a heck of a lot longer to convert and display the string for the same number of iterations. Hm, I was comparing the same number of digits displayed on screen though. One takes 2s to compute and display 10k digits of information on screen, one takes 30s to compute and display 10k digits of information on screen. same number of digits. At least according to the…

> I may be confused. But you have looked at the demo, right?

I have run the demo multiple times, how else would I have generated the time it took for me to run it in the comment above :).

> Hm, I was comparing the same number of digits displayed on screen though. One takes 2s to compute and display 10k digits of information on screen, one takes 30s to compute and display 10k digits of information on screen. same number of digits. At least according to the "progress" output that reads "Digits done".

"Digits done" is the number of correct digits, not the number of displayed digits. It's possible your screen area is too small to notice the difference.

Here is an in progress shot of 10k at 2088 "Digits done" https://i.imgur.com/Fbuw2sc.png

Here is an in progress shot of 100k at 1849 "Digits done" https://i.imgur.com/O1gTogQ.png

As you can see "Digits done" ~= "Digits displayed" in this demo by any means. It simply represents the number of digits that will no longer change as the calculation continues, it is still displaying all the digits every update regardless if they are "done" or not which is where the inefficiencies in rendering come in (and based on the above benchmarks outweigh any other inefficiencies with number size substantially).

Re: A Million Digits of Pi in 9 Lines of JavaScript

#82

Earlier quoted context omitted.

> Sure but one has 10x more digits than the other so takes a heck of a lot longer to convert and display the string for the same number of iterations. Hm, I was comparing the same number of digits displayed on screen though. One takes 2s to compute and display 10k digits of information on screen, one takes 30s to compute and display 10k digits of information on screen. same number of digits. At least according to the…

> I may be confused. But you have looked at the demo, right? I have run the demo multiple times, how else would I have generated the time it took for me to run it in the comment above :). > Hm, I was comparing the same number of digits displayed on screen though. One takes 2s to compute and display 10k digits of information on screen, one takes 30s to compute and display 10k digits of information on screen. same numb…

Aha, I see, thanks!

Re: A Million Digits of Pi in 9 Lines of JavaScript

#83
post #61
post #9

For those of us behind work proxies that dumbly think this site is "domain parking" or worse: http://archive.is/hUo6Q

archive.is blocks resolution from the cloudflare recursive resolver. please consider using web.archive.org which doesn't block anyone.

Good to know, thanks

Re: A Million Digits of Pi in 9 Lines of JavaScript

#84
post #9

For those of us behind work proxies that dumbly think this site is "domain parking" or worse: http://archive.is/hUo6Q

Personal domain. I haven't used it for much over the years. The hosting is static pages on S3. I wonder if there's anything I could do to avoid the domain getting flagged. Maybe it's because the root page on the domain is just a quote.

Not sure. Where the company I work for operates they have some very weird proxy setup (not my company’s rule but the host). Largely it seems only effective at blocking legitimate content for nonsense reasons. My own site gets blocked on occasion, though I’ve lazily let the cert expire. That reminds me....

Anyway I wouldn’t worry too much. It’s likely just stodgy corporate environments that put those kinds of controls in place.

Re: A Million Digits of Pi in 9 Lines of JavaScript

#86

wget " https://www.piday.org/million/" Got you beat, js.

Until you go to examine it and realize it's infinite scrolling via JS and spend all your time trying to hack around that. (Or you just grab the URL out of the request and fetch it a few times directly)
Post reply on HN