Actionscript 3 AS3中的基准测试代码
是否有人有任何指向库的提示或链接来帮助AS3中的基准测试应用程序?我(希望)在寻找类似的东西,但要寻找闪光和空气。欢迎提供任何建议。您可以尝试使用此:。此外,我还发现了一些很好的信息。您可以尝试使用以下方法:。此外,我还发现了一些很好的信息。我经常使用的衡量代码执行时间的快速方法是:Actionscript 3 AS3中的基准测试代码,actionscript-3,performance-testing,Actionscript 3,Performance Testing,是否有人有任何指向库的提示或链接来帮助AS3中的基准测试应用程序?我(希望)在寻找类似的东西,但要寻找闪光和空气。欢迎提供任何建议。您可以尝试使用此:。此外,我还发现了一些很好的信息。您可以尝试使用以下方法:。此外,我还发现了一些很好的信息。我经常使用的衡量代码执行时间的快速方法是: var start_time:int = getTimer(); someComplexCode(); trace("execution time: ", getTimer()-start_time); 这将
var start_time:int = getTimer();
someComplexCode();
trace("execution time: ", getTimer()-start_time);
这将以毫秒为单位给出一个数字 我经常使用的衡量代码执行时间的快速方法是:
var start_time:int = getTimer();
someComplexCode();
trace("execution time: ", getTimer()-start_time);
这将以毫秒为单位给出一个数字 这不是真正用于基准测试,而是一个出色的分析器/性能测试仪。我一直在使用它,从用于web的SWFs到Adobe AIR应用程序再到移动AIR应用程序,无所不包。这并不是真正用于基准测试,而是一个出色的分析器/性能测试仪。我一直在使用它,从用于web的SWFs到Adobe AIR应用程序再到移动AIR应用程序,无所不包。您可以非常轻松地设置基准测试方法:
function test(process:Function, repeat:int = 10):void
{
var time:Number = getTimer();
while(--repeat >= 0) process();
trace(getTimer() - time);
}
这样使用:
// See how long it takes to create 50,000 Sprites and
// add them to the DisplayList.
test(function()
{
var sprite:Sprite = new Sprite();
addChild(sprite);
}, 50000);
您可以非常轻松地设置基准测试方法:
function test(process:Function, repeat:int = 10):void
{
var time:Number = getTimer();
while(--repeat >= 0) process();
trace(getTimer() - time);
}
这样使用:
// See how long it takes to create 50,000 Sprites and
// add them to the DisplayList.
test(function()
{
var sprite:Sprite = new Sprite();
addChild(sprite);
}, 50000);
在此基础上,我创建了一个类似于Python函数的函数。该函数按指定的迭代次数重复回调函数,并返回最快的执行时间。默认值为1000000次迭代
下面的测试程序在我的机器上运行了大约391ms。如果没有trace()
语句,测试执行所需时间不到1ms
TimeIt.as
包{
公共课时间{
导入flash.utils.getTimer;
公共静态函数timeIt(回调:函数,maxIterations:uint=1000000):int{
变量开始时间:int,持续时间:int,最快时间:int=int.MAX\u值;
对于(变量i:int=0;i
测试。作为
包{
公开课考试{
公共功能测试(){
trace('faster Time:',TimeIt.TimeIt(test,10),'ms');
}
公共函数测试():void{
变量k:int,m:int=100;
对于(变量i:int=0;i
Main.mxml
在此基础上,我创建了一个类似于Python函数的函数。该函数按指定的迭代次数重复回调函数,并返回最快的执行时间。默认值为1000000次迭代
下面的测试程序在我的机器上运行了大约391ms。如果没有trace()
语句,测试执行所需时间不到1ms
TimeIt.as
包{
公共课时间{
导入flash.utils.getTimer;
公共静态函数timeIt(回调:函数,maxIterations:uint=1000000):int{
变量开始时间:int,持续时间:int,最快时间:int=int.MAX\u值;
对于(变量i:int=0;i
测试。作为
包{
公开课考试{
公共功能测试(){
trace('faster Time:',TimeIt.TimeIt(test,10),'ms');
}
公共函数测试():void{
变量k:int,m:int=100;
对于(变量i:int=0;i
Main.mxml