This page is a NO-INDEX summary of comments posted in this blog.

Total 29 Comments (1/2 Pages) - Older Comments

1. 2022-11-20 22:22:22 Chris Harvey Comments on Using Faster Exponential Approximation:

Thank you! I was looking for a way to speed up the expensive exp(-x^2) operation in the non-local means denoising algorithm for image processing, where x represents patch similarity. This approximation worked very well. If two patches are similar, then x is small, and the approximation is very accurate. If x is larger than some threshold, then the patches are dissimilar, and so x is large and exp(-x^2) can be approximated as zero directly. (In fact, this latter approximation is necessary as otherwise the contributions from dissimilar patches build up because the approximation is poorer and there are significant artefacts.) I tested this with n=1024 on an 3715*2527 image with patch 7*7 and search window 21*21 and this reduced the computation time from 307.87 s to 15.0171 s when using a naive NLM calculation, so that's a 20.5 times speed-up. I didn't get the 300+ times speed-up you mentioned (I have more going on that just exp calculations), but I'm still pleased with this. If you have suggestions for an even faster calculation, I am eager to know. (I need to avoid a look-up table as the discretization destorys the data).


2. 2020-10-17 09:28:16 dbjdbj Comments on C++ Coding Example, Using Hash Algorithm to Remove Duplicate Number by O(n):
Very good. Again I fail to see why is this C++?


3. 2020-10-17 09:16:26 dbjdbj Comments on Simple C++ Coding Exercise - Use Lookup Table to Eliminate the Condition Checks:
Why is this not C? That is one "sure fire way" to optimize C++ ...


4. 2020-05-24 19:37:45 ACMer Comments on Using Faster Integer Power in Java:
Thanks. yes, you are right.


5. 2020-05-24 18:42:45 Artem Comments on Using Faster Integer Power in Java:
A great trick, but be aware that (b & 1) gives 0 for b = 8, 16, 32. etc.


6. 2020-05-01 19:21:57 Monika Singla Comments on How Many One's Between Number 1 to N ?:
The problem can be approached using string operations. Below is a more generic solution. a = int(input("Please input the value of a: ")) b= int(input("Please input the value of b: ")) n = int(input("Please input the value of n: ")) def counting_machine(a,b,n): c=[] for i in range(a, b+1): d = [d for d in str(i)] c = c+d print(c) b=str(n) count=0 for i, number in enumerate(c): if c[i] == b: count+=1 print(count) counting_machine(a,b,n)


7. 2019-12-19 20:46:43 Antoni Gual Comments on Which is Faster? VBScript or JScript on WSH - A Performance Comparison using Sieve of Eratosthenes:
It's easier than all that! VBS has an specialized instruction to build big strings fast , just pass an array of primes and a separator to join()!


8. 2019-12-19 06:29:37 Antoni Gual Comments on Using Faster Exponential Approximation:
A good idea for an embedded system where a math library is not avaliable. Not practical in a present day PC


9. 2018-10-07 19:21:40 Mushi Mage Comments on Integer Performance Comparison for C++, C#, Delphi:
"In order to make a direct comparison (same PC), the testing for Linux64 bit code generated by Delphi Tokyo compiler is done at Linux Sub System on Windows. It is slow but may be totally a different story if you deploy the binaries directly on a truly Ubuntu Linux server (but in this case, you have to make sure the Linux Server and Windows PC are exactly the same specs)" The performance cited for Linux 64 Delphi is worthless given the overhead entailed in running as a subsystem.


10. 2018-09-05 09:30:23 Rudy Velthuis Comments on Integer Performance Comparison for C++, C#, Delphi:
It looks as if the Delphi Linux64 compiler doesnโ€˜t perform any opimization. The Delphi Win64 compiler doesnโ€˜t optimize inside a try-except block. Try it and look at the generated code in the CPU window.


11. 2017-08-16 01:54:09 sonofusion82 Comments on Counting the number of Leading Zeros for a 32-bit Integer (Signed or Unsigned):
__builtin_clz() intrinsic function usually use processor's special instruction, so it is a lot faster than any C implementation unless the compiler is able recognize the pattern and optimize it out. I usually like to use godbolt.org compiler explorer to see what the compiler is doing with my code. I've copied your code to there and you can see how each implementation is being compiled. https://godbolt.org/g/VcW4Mo


12. 2017-04-11 14:33:07 daniel Comments on Integer Performance Comparison for C++, C#, Delphi:
PS: it would be nice if the bars in your graphics would be sorted by speed and not by language ๐Ÿ™‚


13. 2017-04-11 14:33:00 ACMer Comments on Integer Performance Comparison for C++, C#, Delphi:
Here is another interesting comparison: JAVA x64 is even faster than compiled Delphi/C++ code.


14. 2017-04-11 14:31:19 daniel Comments on Integer Performance Comparison for C++, C#, Delphi:
I would die to see a Java comparison also!


15. 2017-03-24 21:24:54 Charles Programmr Comments on Which is Faster? VBScript or JScript on WSH - A Performance Comparison using Sieve of Eratosthenes:
Since some of us have extensive experience with VBScript and less with JScript/Javascript, a few milliseconds isn't going to make up for the time we'd waste not using VBScript.


16. 2017-01-23 09:56:04 ACMer Comments on Which is Faster? VBScript or JScript on WSH - A Performance Comparison using Sieve of Eratosthenes:
Thank you. You have make your point quite clear. And it is good to know the performance hits in VBScript is the string concatenation. But JScript is still slightly faster.


17. 2017-01-23 09:51:23 Rinzwind Comments on Which is Faster? VBScript or JScript on WSH - A Performance Comparison using Sieve of Eratosthenes:
About the looks... JavaScript is just ugly imho (but PowerShell triumphs JavaScript in uglyness and unforgiveness ;)) and misses stuff like option explicit and seamless enumerators. VBScript looks friendlier to me and handles COM-objects cleaner. Anyway, one can even use them both in the same project. JScript that calls VBScript functions and viseversa in a wsh file. HTA ('html applications') is also a forgotten beauty for sysadmins/devs. A pitty the don't get the love from MS. But it is stable proven technology and 'just works and runs'. MS is all into ,NET


18. 2017-01-23 09:40:12 Rinzwind Comments on Which is Faster? VBScript or JScript on WSH - A Performance Comparison using Sieve of Eratosthenes:
Btw if one wants to do without adodb.stream, one can use a buffer string and append to that shorter one until it reaches a specific length or iterations. This also circumvents making many many many string copies of a large string at each concat. Quick example (result is 1031 ms) S = "" Dim buf buf = "" For i = 0 To N If Primes(i) Then ' concatenate numbers into strings If Len(buf) > 1000 Then s = s & buf buf = "" End If buf = buf & i & ", " End If Next s = s & buf


19. 2017-01-23 09:24:54 Rinzwind Comments on Which is Faster? VBScript or JScript on WSH - A Performance Comparison using Sieve of Eratosthenes:
This is a flawed example which just points at the fact that one needs to think about string concatenation when handling lots of concatenations. As a developer should know, string concats create new string objects in memory. So if one needs to do lots of additions one should use a stringbuilder class or similar. Apparently JS handles this internally. In VBScript one can use a ADODB.Stream object for this. Anyway, such a specific test is useless when comparing two languages. This one was comparing only lots of string concatenations without optimization or thinking about implementation. When adjusted the result on my vm is plus/minus JScript: 812 ms VBScript: 969 ms Code: Option Explicit Dim t1, t2, primes, m, i, j, s, a t1 = Timer Const N = 1000000 ReDim Primes(N) ' VBScript holds 1000000+1 elements Primes(0) = False Primes(1) = False For i = 2 To N Primes(i) = True Next 'WScript.Echo Timer - t1 M = Sqr(N) For j = 2 To M If Primes(j) Then i = j * j a = N+1 Do While i < a ' Filtering out non-prime numbers Primes(i) = False i = i + j Loop End If Next 'WScript.Echo Timer - t1 Dim utf8s Set utf8s = CreateObject("ADODB.Stream") utf8s.Open S = "" For i = 0 To N If Primes(i) Then ' concatenate numbers into strings utf8s.WriteText i & ", " 'S = S & i & ", " End If Next utf8s.Position = 0 s = utf8s.ReadText ' Just output the length WScript.Echo Len(s) 'WScript.Echo Timer - t1


20. 2016-08-31 20:07:56 ACMer Comments on Which is Faster? VBScript or JScript on WSH - A Performance Comparison using Sieve of Eratosthenes:
Yes, VBScript doesn't have advanced/elegant programming syntax, but it is sufficient in some small, windows admin tasks.


21. 2016-08-31 15:12:27 Fernando Di Ramos Comments on Which is Faster? VBScript or JScript on WSH - A Performance Comparison using Sieve of Eratosthenes:
Thx for sharing. I just think that the form of writing in Visual Basic is much ugly. Yes, the decision is aesthetic. And that's why I write in JScript. cheers


22. 2016-06-13 20:39:10 Bruno Comments on Using Faster Exponential Approximation:
well, it's broken the whitespaces .-.


23. 2016-06-13 20:38:12 Bruno Comments on Using Faster Exponential Approximation:
Benchmark Time(ns) CPU(ns) Iterations -------------------------------------------------- bench_math_exp/1 95 94 7241354 bench_math_exp/10 95 95 7499946 bench_math_exp/15 94 94 7500027 bench_math_exp/20 94 94 7500027 bench_exp256/1 17 17 40384693 bench_exp256/10 17 17 41176471 bench_exp256/15 17 17 39622567 bench_exp256/20 17 17 40384460 bench_exp1024/1 10 10 72413543 bench_exp1024/10 9 9 65624795 bench_exp1024/15 10 10 74999464 bench_exp1024/20 9 9 72413543 exp of 1, 10, 15 and 20, using google benchmark and -O3, it is odd that exp1024 is faster than exp256, but if i use -O0, exp1024 is slower and i don't know why this is happening.


24. 2015-06-28 20:03:14 ACMer Comments on Simple C++ Coding Exercise - Use Lookup Table to Eliminate the Condition Checks:
The modern compilers are often clever enough to figure out best way to optimise the code.


25. 2015-03-03 10:26:45 ACMer Comments on Simple C++ Coding Exercise - Use Lookup Table to Eliminate the Condition Checks:
Lookup Table is frequently used.


Older Comments

–EOF (Coding For Speed) —

GD Star Rating
loading...
59 words
The Permanent URL is: List of Comments