View unanswered posts | View active topics It is currently Fri Dec 27, 2024 9:29 am



Reply to topic  [ 4 posts ] 
 Lua Performance 
Author Message
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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.


Fri Aug 14, 2009 6:33 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Lua Performance
I agree.


Sat Aug 15, 2009 5:46 am
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post 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


Sat Aug 15, 2009 10:06 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Lua Performance
that is for 200px long rays at 100% accuracy though.
thats a really checking structure though..


Sat Aug 15, 2009 10:15 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.126s | 13 Queries | GZIP : Off ]