Data Realms Fan Forums
http://45.55.195.193/

Lua Performance
http://45.55.195.193/viewtopic.php?f=73&t=16216
Page 1 of 1

Author:  Grif [ Fri Aug 14, 2009 6:33 pm ]
Post subject:  Lua Performance

Alright well we all know (pretty well) that Lua doesn't run as fast as the RTE engine itself. So, what's the best way to check various things, what lags most in Lua (I'm voting for for loops) and what're the best ways to avoid bogged down code.

For square checks, the box class is king.
For radial, SceneMan:ShortestDistance.Magnitude seems to be the best.
MORays are really not ideal for anything that I've done (yet) but they do have uses.

So how about we do some testing? What functions lag least/most, etc.

Author:  mail2345 [ Sat Aug 15, 2009 5:46 am ]
Post subject:  Re: Lua Performance

I agree.

Author:  piipu [ Sat Aug 15, 2009 10:06 am ]
Post subject:  Re: Lua Performance

I compared the times it takes to cast 1000 rays with different methods. With timescaling turned off, 1000 CastMORays took MSPF from 4 to 15-180 in tutorial bunker. With CastObstacleRay MSPF was between 15 and 200. CastStrengthRay went as high as 200-350 milliseconds per frame. I used the following script attached to an actor:
Code:
function Create(self)
   self.state = 1
   self.uselessvector = Vector(0,0)
end

function Update(self)
   if self:GetController():IsState(8) then
      self.state = self.state + 1
      if self.state > 4 then
         self.state = 1
      end
   end
   for i=1 , 1000 , 1 do
      if self.state == 1 then
         
      end
      if self.state == 2 then
         self.MOID = SceneMan:CastMORay(self.Pos,Vector(200 * math.cos(self:GetAimAngle(false)) , -200 * math.sin(self:GetAimAngle(false))) , 0 , 0 , false , 0)
      end
      if self.state == 3 then
         self.dist = SceneMan:CastObstacleRay(self.Pos,Vector(200 * math.cos(self:GetAimAngle(false)) , -200 * math.sin(self:GetAimAngle(false))) , self.uselessvector , self.uselessvector , 0 , 0 , 0)
      end
      if self.state == 4 then
         self.dist = SceneMan:CastStrengthRay(self.Pos,Vector(200 * math.cos(self:GetAimAngle(false)) , -200 * math.sin(self:GetAimAngle(false))) , 1500 , self.uselessvector , 0 , 0 , true)
      end
   end
end

Author:  Geti [ Sat Aug 15, 2009 10:15 am ]
Post subject:  Re: Lua Performance

that is for 200px long rays at 100% accuracy though.
thats a really checking structure though..

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/