generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How To See The Difference In Speed And Efficiency?

Previous Thread :: Next Thread 
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
11 Apr 2015 06:35 AM
Hello guys,

I would just like to know how you would compare 2 scripts. Say you had 1 script, and decided to add a few locals in it, how would you compare the speed? Same goes for other things.

Example:

Script 1:

while true do
x = 10
print(x)
wait(1)
end

Script 2:

while true do
local x = 10
print(x)
wait(1)
end

How would you see if it is faster?

Also, could you tell me all the ways you know how to make a script has fast and as efficient as possible.
Report Abuse
murcury57 is not online. murcury57
Joined: 30 Jun 2010
Total Posts: 90299
11 Apr 2015 06:36 AM
[ Content Deleted ]
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
11 Apr 2015 06:46 AM
So like this?

while true do
local Started = tick()
local x = 10
local Ended = tick()
print(x)
print(Started-Ended)
wait(1)
end

Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Apr 2015 07:32 AM
You'd have to put the print before your diff
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
11 Apr 2015 08:27 AM
function TestSpeed(func)
local start = tick()
func()
return tick() - start
end


local n1 = TestSpeed(function()
x = 10
print(x)
wait(1)
end)

local n2 = TestSpeed(function()
local x = 10
print(x)
wait(1)
end)

print("Time to execute test#1: "..n1)
print("Time to execute test#2: "..n2)
local faster = (n1 < n2) and "test#1" or "test#2"
print("Faster: "..faster)
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
11 Apr 2015 08:29 AM
Also, my results:

10
10
Time to execute test#1: 1.0176703929901
Time to execute test#2: 1.0070385932922
Faster: test#2
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
11 Apr 2015 10:25 AM
^
Thanks!
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
11 Apr 2015 10:33 AM
np
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image