Test computer performance with Julia set

Source: Internet
Author: User
Tags time limit
Performance

Long time no come, this time to bring you a little dongdong.

We all know that Julia set is an iterative algorithm, that is, the results of the operation are put into the algorithm calculation, so that the results are close to the real value

For example, we calculate π,e using this algorithm.

Julia sets have many forms that require a lot of resources to produce results. And we can use this algorithm to test computer performance.

Because you use BitmapData support, play with FlashPlayer8.0.

/**
ActionScript Source File--Created with SAPIEN Technologies Primalscript 3.1

@class test.as
@package
@author tcper@163.com Loki_tang
@codehint
@example: Import Test;
var someobject:test=new Test;
Someobject.tester (. 01);
@tooltip
*/
Import Flash.display.BitmapData;
Class Test extends MovieClip {
private Var N:number;
private Var Cx:number;
private Var Cy:number;
private Var X2:number;
private Var Y2:number;
private Var Rgb:number;
private Var Timegot:number;
private Var Rgboffset:number;
private Var Pixelpos:number;
private Var Mc:movieclip;
private Var Mcorigin:movieclip;
private Var Mybitmapdata:bitmapdata;
A,b are all the parameters of Julia set
private static var a:number =. 5;
private static var b:number =. 55;
private static var pixelnum:number = 0;
private static var Timelimitation:number = 4000;//Calculation time limit
function Test () {
Bitmapcreator ();
}
Private Function Bitmapcreator (): BitmapData {
Mybitmapdata = new BitmapData (A, false, 0XCCCCCCCC);
return mybitmapdata;
}
Private Function Mccreator (): MovieClip {
Mcorigin = This.createemptymovieclip ("MC", This.getnexthighestdepth ());
return mcorigin;
}
Private Function getRGB (I:number,u:number): number {
RGB = (i-u) *200;
return RGB;
}
Private Function Getpixelpos (I:number): number {
Pixelpos = Math.floor ((i+1.5) *133.3);
return pixelpos;
}
Private Function Timecheck (i:number): Boolean {
if (Gettimer ()-i) return true;
} else {
return false;
}
}
public method;
public static function Pixelstatistic (): number {
return pixelnum;
}
Public Function Tester (u:number): Void {
Rgboffset = Math.floor (100*math.random ());
Timegot = Gettimer ();
var mc = Mccreator ();
Mc.attachbitmap (Bitmapcreator (), this.getnexthighestdepth ());
mc._x = mc._y=-200;
Here is the Julia algorithm.
for (var i = -1.5; i<=1.5; i = u) {
for (var j = -1.5; j<=1.5; j = u) {
CX = i;
cy = j;
for (var n = 1; n<=100; n++) {
pixelnum++;
x2 = cx*cx-cy*cy+a;
y2 = 2*cy*cx+b;
CX = x2;
cy = y2;
if (cx*cx+cy*cy>4) {
Break
}
if (!timecheck (Timegot)) {
Return
}
}
Bitmapcreator (). SetPixel (Getpixelpos (i), Getpixelpos (j), getRGB (N,rgboffset));
}
}
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.