Giter Site home page Giter Site logo

Comments (2)

mbolt35 avatar mbolt35 commented on July 3, 2024

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.

ddyer0 avatar ddyer0 commented on July 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.