PDA

View Full Version : Good way of determin user machine performance



nook
February 20th, 2009, 03:17 AM
Hi. I'm thinking of varying content in my app depending on user machine performance.
Is there any good standard methods? Like a mini-benchmark-test first thing in the app. I guess you could measure both the time of a function (quick but true?) or framrate of some drawing.

:: nook

justkevin
February 20th, 2009, 02:43 PM
I don't know of a standard method, probably timing any cpu-intensive activity will give a good ballpark, since Flash doesn't get any hardware acceleration. I'd guess the best method would be to simulate the likely activities your app will be performing for a few dozen frames, drop the lowest value and calculate the average fps.

I wouldn't rely on timing the behavior of just one expensive function (like applying a blurFilter) in case Adobe releases an update that happens to optimize the function you were using as a benchmark.

grandpaw broon
February 20th, 2009, 02:46 PM
How come Flash dont have Hardware Support? Just wondered.

McGuffin
February 20th, 2009, 03:32 PM
Flash did get handware-acceleration as of Flash Player 10 for certain GPUs. Not sure if this is useful, but found this by Googling:
http://www.bytearray.org/?p=245

As far as telling how quick a user's computer is by function time, my intuition tells me that would be a highly unreliable method. Your margin of error would be massive, and you'd be checking against differences in milliseconds. You can read framerate in AS3, use that as a measure and try to maintain a minimum acceptable level, or just give the user a choice of levels of performance.

nook
February 23rd, 2009, 11:37 AM
Thank you all for helpful input!

dail
February 23rd, 2009, 01:43 PM
http://codeendeavor.com/guttershark has a method for estimating CPU capabilities. I've not actually looked at the internals of the method, but it might give you some pointers.

McGuffin
February 23rd, 2009, 02:18 PM
var mc:MovieClip=new MovieClip();
mc.graphics.beginFill(0xFF0066);
mc.graphics.drawRect(0, 0, 200, 200);
mc.graphics.endFill();
var blurFilter:BlurFilter=new BlurFilter(4,4,1);
var filters:Array=[];
var passes:int=3;
var h:int=0;
var i:int=0;
var t:Number;
var benchmark:Number;
for(h;h<passes;h++)
{
t=getTimer();
for(i=0;i<((h+1)*200);i++)
{
filters.push(blurFilter);
mc.filters=filters;
}
benchmark=(getTimer() - t);
filters=[];
}
if(benchmark<45)cpuEstimation="fast";
else if(benchmark<80)cpuEstimation="medium";
else cpuEstimation="slow";


Taken from here (http://gitweb.codeendeavor.com/?p=guttershark.git;a=blob_plain;f=src/as/net/guttershark/control/DocumentController.as;hb=HEAD). There's no copyright information provided with the file, but I would check out his links to make sure it would be alright to use this snippet in a project, and what copyright if any needs to be included if you use this source.

It seems to just loop through a blur filter a few hundred times and check if there were any hangups. Not a bad method if you're going to check for this, but I'm not sure if it's reliable.

BeerOclock
February 23rd, 2009, 04:06 PM
Sorry if this is a little bit off topic but its something I have wondered.

I notice that most flash games have a High, Medium, Low setting.

Is this a built-in Flash feature? Or is it something that all these developers just happened to implement?

If its built-in, what exactly does it affect? Just the quality of the vector graphics? Or more?

I find that even when an intense flash game is running really slowly because a lot of stuff is going on, switching from High to Low quality doesnt improve the performance at all. At least on my machine, there is never a point in switching to low quality.

But Is there any way to detect which setting the user has selected? I'm thinking that you can detect those settings and then do some substantial performance enhancements (ie, cutting corners) at runtime.

Basically, instead of trying to determine how fast their computer is, you just let them tell YOU how fast the Flash app is running. If they select LOW quality, then you need to cut any corners you can in your calculations and graphics.

Any thoughts?

TheCanadian
February 23rd, 2009, 05:02 PM
High, medium and low (and don't forget best) quality refers to how graphics (both bitmap and vector) are rendered. It changes how and if vectors are anti-aliased and if bitmaps are smoothed. It is an extremely useful tool to enhance the performance of a movie since a large (if not the largest) percent of frame time is spent actually drawing objects to the stage. You can set the quality of a Flash movie using the flash.display.Stage.quality (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Stage.html#quality) property.


Basically, instead of trying to determine how fast their computer is, you just let them tell YOU how fast the Flash app is running. If they select LOW quality, then you need to cut any corners you can in your calculations and graphics.That's a great idea and is often used in Flash movies. Many movies have options for turning off shadows or particle effects or whatever to enhance performance of a movie.

nook
February 23rd, 2009, 05:51 PM
dail:
Couldn't find such method on the site you mentionen?

McGuffin:
Looking like something I could use. Thanks again.

dail
February 23rd, 2009, 10:59 PM
McGuffin found it for you :)

nook
February 24th, 2009, 04:00 AM
Indeed. :)

bonnieraymond
February 24th, 2009, 06:15 AM
McGuffin's code is great but I don't think it's really solve the idea. I see that the MovieClip "mc" never been added to the Stage so the Flash never render anything. So this code might be a good tool to measure computer's calculation speed rather than computer's graphic.

nook
February 24th, 2009, 08:28 AM
True. Didn't check that thoroughly.
But I guess adding the mc and then removing it would solve that right? Just need to readjust the benchmark limits.

McGuffin
February 24th, 2009, 12:01 PM
I'll still stand by my original comment and say you're better off asking the user for a level of machine performance or calculating it as the movie runs through the framerate. I definitely cannot vouch for the code's worth, I just grabbed it from the git tree and pasted it.

nook
February 24th, 2009, 12:46 PM
Yes, that's an obvious oportunity.
But I'm currently working on an app. for 3-4 year olds so if I'm gonna use any performance setting I have to calculate it myself. :)