-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
performance aspects of crossbridge code #58
Comments
This may seem strange, but try using Also, are you running that code on repeat in a tight loop and taking averages? Are you running in a function? I'd guess that code should execute at about double the time of crossbridge, and the big reason why that's the case is that the crossbridge compiles to code that performs these operations on the domain memory byte array, and the AS3 code is going to create managed objects. If you think about it in those terms, simple load/compare/store operations on a byte array are going to be a great deal faster. I won't lie, I'm surprised that the crossbridge code runs that much slower than the native windows test, but a good way to generically group Crossbridge performance is to compare to .NET execution. Crossbridge should be as fast (if not slightly faster) in some calculations as compared to .NET. |
I'm running a real test with 2^24 x 2 distinct function calls in the loop. From other experiments, I've determined that a lot of the difference is function call overhead. "Everything" in C is 2 seconds. "Everything" cross-compiled is 6 seconds. Of that 6 seconds, about half is function The as3 test loop overhead, including the function calls, is about 13 seconds Bottom line, in ballpark numbers: Cross compiling has a 3x speed penalty, but still 3x faster The part of this that is surprising to me is that the cross compiled code Also note that this is not necessarily representative of what can be achieved |
I have an unexpected (to me) result, comparing native C code with the same
code executed by crossbridge, to the same code manually translated to actionscript.
The relative speeds are
2.043 native windows code
6.707 crossbridge compiled native code
25.3 native actionscript code
Losing a factor of 3.7 going from native C to SWC is not too bad, but I'm totally
shocked that the carefully written actionscript, using exactly the same algorithm,
should be a factor of 10 slower than native C. The code in question is crunching
numbers with doubles (in C) vs. with :Number in actionscript.
Native C:
double m = min (nr, min (ng, nb));
double nm = nv-m;
double ns = ns = nm / nv ;
double r1 = (nv - nr) / nm ;
double g1 = (nv - ng) / nm ;
double b1 = (nv - nb) / nm ;
double nh;
Actionscript:
The text was updated successfully, but these errors were encountered: