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. 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 wha…
We automatically generated all the results in this quiz from the programs on the site. None of the loops were optimized out, we ran basically a binary search to figure out the maximum number of iterations you could run in a second. Results and compiler optimizations will of course vary across computers, but they were correct on my laptop on the day that we ran them (in Sept. 2015). If you want to reproduce this on yo…
How much your computer can do in a second
211–220 of 244 posts
Re: How much your computer can do in a second
#212Earlier quoted context omitted.
> E.G: wondering why you see electron apps everywhere now ? Because until now making a beautiful, powerful and modern app with a portable GUI was something only a few people would be able to do. You should really take a look at Python and Qt. Beautiful, easily maintained and well-performing cross-platform apps have been a possibility with this pair for the better part of a decade. Anki is my favorite example, but the…
I'm a python expert, I know. You are missing the point: electron apps target front end devs. They are more of them, a lot more, than any other type of dev and they don't want to learn a new tech. Hell they even ported js to the server, an awful language, to avoir using something else. Plus saying qt is easy to use to them is like saying java is productive to a python dev. You are not on the same scale.
There are still some of us that do actual native frontends.
Re: How much your computer can do in a second
#213Earlier quoted context omitted.
> so you cannot just send a bunch of pixel info to webgl, you have to do each pixel seperately. Why do you think that? You certainly can get previously modified pixels, you can send millions of pixels to WebGL with a single call (as a texture). Nobody calls glReadPixels millions of times, that's a bad idea. :) You might want to investigate multipass rendering techniques. Small kernel convolutions, for example, are st…
>It sounds like you're missing render to texture and multipass techniques, the ways to use textures as compute I/O. To do multipass in WebGL and share the results of computation from one pass to the next, you create an offscreen framebuffer for your results, and you render directly to that framebuffer. You can then use the result as an input texture for the next pass (via glCopyTexImage2D) or you can read back the bu…
Whoa, hang on. Hey I only mean this to be helpful not insulting, but it sounds to me like you may have some misconceptions about the way WebGL works. I know how easily that can be taken the wrong way, especially in text, so again I apologize in advance and I don't mean that to be rude at all. It would be best to back up and understand WebGL.
If you're doing image processing in WebGL, then to write many pixels to a framebuffer all at once, you draw a single polygon that covers the entire viewport. Your shader is applied in parallel to all pixels drawn. That is how ShaderToy works, it renders a single quad to the viewport and applies whatever shader you give it, the GPU runs that shader on all pixels rendered.
There are never hundreds of thousands of buffer read calls, you only need a handful. For a blur, you only have to do a buffer read once, and your shader samples the 3x3 neighbor pixels.
You don't need OpenCL, that's a level of complication you don't need. I may have given the wrong impression with that link.
Check out this image processing tutorial using basic WebGL 1, and pay attention to how it works:
https://webglfundamentals.org/webgl/lessons/webgl-image-proc...
Here is the demo from that article that uses the techniques I've been talking about. All of the filters in this demo are doing neighborhood computations. And note you can apply multiple filters. There is no texture copy here, this tutorial renders directly to a texture in one pass, and then samples that texture in the next pass and so on. The iterations or feedback that you're looking for happen by combining render-to-texture with drawing the viewport polygon multiple times.
https://webglfundamentals.org/webgl/webgl-2d-image-processin...
Re: How much your computer can do in a second
#214Why isn't the first Python loop (that does nothing but pass) optimised away completely?
You could think of them as thought experiments e.g. "how many ADD's can we make on a single thread on an average PC?" rather than "What would the runtime of this C program be on an average PC?". Since the results were generated without optimizations, at least for the C programs, there is not much point in talking about runtime.
Re: How much your computer can do in a second
#215Re: How much your computer can do in a second
#216Earlier quoted context omitted.
> Unfortunately devs invest in the fastest equiplent, so they don't experience how their code runs on the average end user who doesn't upgrade every couple years. As someone who doesn't spend much on computer upgrades, I notice this everywhere . Especially when it comes to web development, where everything is optimized for chrome on mac. Don't have a laptop made in the last year? Enjoy a janky-scrolling slow-loading…
Also, the web devs have no idea how slow the connections in even the western world can be. At least I think so, if they had to experience a 4 Mbit/s connection more often they wouldn't push for Angular and such.
Re: How much your computer can do in a second
#217If, like me, you spend most of your time in high-level, garbage collected "scripting" languages, it's really worth spending a little time writing a few simple C applications from scratch. It is astonishing how fast a computer is without the overhead most modern languages bring in. That overhead adds tons of value, certainly. I still use higher level languages most of the time. But it's useful to have a sense of how f…
And chez is _fast_.
Re: How much your computer can do in a second
#218Earlier quoted context omitted.
Worth checking out Common Lisp. It's as high-level language as you can get, and yet good compilers (like SBCL, or like commercial ones from Franz and LispWorks) can compile it to tight assembly with performance very close to that of C++ (you need to disable some runtime checks for that though, but you can do that on a per-function level, so it's much less of a problem than one thinks).
Haskell is also really fast. On most Stack Overflow questions asking "why is this Haskell program slow", there's often a detailed answer with an implemention that's about as fast as -- or even faster than -- C: http://stackoverflow.com/questions/42771348/why-is-haskell-s... http://stackoverflow.com/questions/6964392/speed-comparison-... http://stackoverflow.com/questions/29875886/haskell-why-does...
I thought I would implement some naive versions:
For he second link, I just whipped up this naive in chez scheme, and it runs in 0.5s, and that should really be the baseline: https://pastebin.com/JXGLA4TR Incidentally this seems to be on par with the fastest haskell version posted that does not use precomputed primes for factorisation. It could be made a lot faster by using only primes, but I couldn't be bothered.
And I doubt you will find a haskell version that gets the longest collatz-sequence that is faster than this: https://pastebin.com/FAdiHA3X (0.01s using gcc -O2). Yet again, a simple algorithm, but this time with bolted-on memoization.
Edit: The first link contains the most naive and slow fibonacci function. It might be mathematically elegant, but it is dirt slow.
(define (fib n)
(let loop ([n n] [a 0] [b 1])
(if (zero? n)
b
(loop (- n 1) b (+ a b)))))
That one takes 0.1s calculating the 100.000th fibonacci number, and there are even faster ways.Re: How much your computer can do in a second
#219If, like me, you spend most of your time in high-level, garbage collected "scripting" languages, it's really worth spending a little time writing a few simple C applications from scratch. It is astonishing how fast a computer is without the overhead most modern languages bring in. That overhead adds tons of value, certainly. I still use higher level languages most of the time. But it's useful to have a sense of how f…
Worth checking out Common Lisp. It's as high-level language as you can get, and yet good compilers (like SBCL, or like commercial ones from Franz and LispWorks) can compile it to tight assembly with performance very close to that of C++ (you need to disable some runtime checks for that though, but you can do that on a per-function level, so it's much less of a problem than one thinks).