Property Frame Time Costs
Here is a list of Part
properties and frame times that resulted from changing them in a benchmarking plugin.
The higher the number, the slower changing that property programmatically is. Numbers are immediate frame time, not anything else. Units are in microseconds. All results are based on the 50th percentile during a set of trials.
These numbers do not matter if you are doing any of these only sometimes, since they are microsecond calculations. However, when done multiple times per frame, it makes a difference. For example, this might help you find the best culling method for parts (transparency).
Here is the .bench
file if you would like to test this yourself:
local Part = workspace.Part
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CreatedParts = {}
local Properties = {
BrickColor = BrickColor.random(),
CastShadow = false,
Color = Color3.new(math.random(), math.random(), math.random()),
Material = Enum.Material.Neon,
Reflectance = math.random(),
Transparency = math.random(),
Name = tostring(math.random()),
Parent = ReplicatedStorage,
Size = Vector3.new(math.random(), math.random(), math.random()),
Position = Vector3.new(math.random(), math.random(), math.random()),
Orientation = Vector3.new(math.random(), math.random(), math.random()),
CanCollide = false,
CanTouch = false,
CollisionGroupId = math.random(),
Anchored = true,
CustomPhysicalProperties = PhysicalProperties.new(math.random(), math.random(), math.random(), math.random(), math.random()),
Massless = true,
RootPriority = math.random(),
Shape = "Ball",
AssemblyLinearVelocity = Vector3.new(math.random(), math.random(), math.random()),
AssemblyAngularVelocity = Vector3.new(math.random(), math.random(), math.random()),
CFrame = CFrame.new(math.random(), math.random(), math.random()) * CFrame.fromEulerAnglesXYZ(math.random(), math.random(), math.random()),
}
local Benchmark = {
ParameterGenerator = function()
end;
Functions = {},
}
for Property, Value in pairs(Properties) do
Benchmark.Functions[Property] = function()
local Old = Part[Property]
for _ = 1, 10 do
Part[Property] = Value
Part[Property] = Old
end
end
end
return Benchmark
That’s it! Save this if you’re a programmer trying to optimize your game.
Thanks for reading ^v^