Posts Tagged math

Faster Math.abs

Tags: , , , , , ,

Math.abs is a commonly-used utility function for taking the absolute value of a Number. However, there’s no special-case version for taking the absolute value of an int. Of course Math.abs will work for int values, but we can do it faster. Read on for a couple of ways.

Read the rest of this article »

18 Comments

How To Use a Profiler To Get Better Performance

Tags: , , , , , ,

The site has had many articles about improving the performance of your app, but never discussed the basic methodology on which all optimizations should be based. Today’s article will go over a scientific approach to optimizing that makes use of a tool known as a profiler and demonstrate using an AS3 application just why it’s so important to usage such a tool.

Read the rest of this article »

22 Comments

Improving Vector3D

Tags: , , , , , , , , ,

The Vector3D class debuted in Flash Player 10.0 as Adobe’s official implementation of, well, a 3D mathematical vector (not the pseudo-Array class Vector). Weirdly, it has a w component and is therefore technically a 4D vector, but its API inconsistently make use of the fourth dimension. There are also strange oversights, inefficiencies, and functionality it really should have always had. Read on for my custom Vector3D derivative—Vector3DExt—that fixes all of these problems by extending and improving on the original.

Read the rest of this article »

5 Comments

Inline Math.ceil() Part II

Tags: , , , , ,

I’ve been looking at a lot of AVM2 bytecode recently with the excellent Nemo440 AIR app. Some of the code was using my inline Math.ceil() function and I noticed that the int() cast is implemented like any other function call. Today’s article will show you how to optimize the inline Math.ceil() call even further by avoiding this function call.

Read the rest of this article »

18 Comments

Inlining Math Functions

Tags: , , , ,

As a followup to my article on Inlining Math.ceil(), I decided to inline some more functions in the Math class. Read on for the code as well as tests proving correctness and speed.

Read the rest of this article »

3 Comments

Inline Math.ceil()

Tags: , ,

Math.ceil() is a common, mundane function that you likely call all the time. I know I do. If performance gets to be important and you have a Math.ceil() in some inner loop or frequently called function, consider inlining it. Below I’ll show you how and provide a test app showing you just how much CPU time you’ll save.

Read the rest of this article »

11 Comments