Advertisement
Guest User

Color3 Lerp Testing

a guest
May 16th, 2016
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. function testRun()
  2.     local a = Color3.new(0,0,0)
  3.     local b = Color3.new(1,1,1)
  4.  
  5.     local time = tick()
  6.     result = Color3.new(
  7.        (b.r - a.r)*0.5 + a.r,
  8.        (b.g - a.g)*0.5 + a.g,
  9.        (b.b - a.b)*0.5 + a.b
  10.     )
  11.     local rA = tick()-time
  12.  
  13.     local time = tick()
  14.     local c = Vector3.new(a.r,a.g,a.b):lerp(Vector3.new(b.r,b.g,b.b), 0.5)
  15.     result = Color3.new(c.X,c.Y,c.Z)
  16.     local rB = tick()-time
  17.    
  18.     local time = tick()
  19.     result = a:lerp(b, 0.5)
  20.     local rC = tick()-time
  21.    
  22.     return rA,rB,rC
  23. end
  24.  
  25. local aSum,bSum,cSum = 0,0,0
  26.  
  27. for i = 1,1000 do
  28.     local a,b,c = testRun()
  29.     aSum = aSum + a
  30.     bSum = bSum + b
  31.     cSum = cSum + c
  32.     print(i) --Just to see progress on the 1000 iterations.
  33.     wait()
  34. end
  35.  
  36. print("Sharksie's method average time: "..aSum/1000)
  37. print("ScriptOn's method average time: "..bSum/1000)
  38. print("New Color3:Lerp method average time: "..cSum/1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement