Comments (2)
This may seem strange, but try using if
conditionals instead of the ternary ops in the AS3, and see if that gives you better results. I can't say that I've examined the .abc
output generated by nested ternary operations, but in my experience, AS3 handles execution branching in an inconsistent way. I agree that that number is surprising, but I have also seen various "swings" in timing AS3 algorithms. There are a few variables at play including Flash Player version, Debugger vs Release player. In browser versus stand-alone, etc...
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.
from crossbridge.
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
call overhead for internal calls, presumably not using the same stack frames as normal
AS3; the function arguments are doubles and pointers to double, which would not
be possible in normal AS3. So there's approximately a 3x speed penalty for cross-compiled
code (of this type).
The as3 test loop overhead, including the function calls, is about 13 seconds
The actual number crunching is about 10 seconds in native as3; compared to
about 3 seconds in cross compiled code, so there's a further 3x penalty for using proper
as3 data and stack structures.
Bottom line, in ballpark numbers: Cross compiling has a 3x speed penalty, but still 3x faster
than writing pure as3.
The part of this that is surprising to me is that the cross compiled code
is so much better than AS3 - I would have expected it to be much closer in speed.
Also note that this is not necessarily representative of what can be achieved
in pure byte-pushing code. My test is heavy on floating point and function calls.
from crossbridge.
Related Issues (20)
- Merge codebase to the official SWIG project HOT 3
- Cannot build master branch on Windows platform using Cygwin HOT 6
- Cannot build master branch on Mac platform using Travis-CI HOT 2
- getting started HOT 7
- Building the SDK HOT 1
- pthreads and workers support HOT 10
- getting started HOT 17
- GDB. HOT 1
- fopen with directories makes fseek throw HOT 2
- PlayerKernel.open() throws exception when opening ISpecialFile file with O_TRUNC
- Cygwin dll files is missing HOT 1
- simple app used flashcc socket throws 'terminate called after throwing an instance of 'AS3::ui::var'' HOT 1
- Can't get it to work with SFML
- how do i link a static lib which build by cygwin HOT 1
- Use crossbridge to compile client.c to swc but failed because of a link error HOT 1
- gcc in cygwin is not support windows 10
- archive project? HOT 4
- crossbridge and C++11 HOT 10
- Disable output in adl
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crossbridge.