local Workspace = game:GetService("Workspace") local PART_SIZES = { 0, 25, 100, 1000, 5000, 10000 } local hitbox = Workspace:FindFirstChild("Hitbox") local hitboxCf = hitbox.CFrame local hitboxSz = hitbox.Size local start = hitbox.CFrame * CFrame.new(hitbox.Size / 2) local finish = hitbox.CFrame * CFrame.new(-hitbox.Size / 2) local overlap = OverlapParams.new() overlap.FilterType = Enum.RaycastFilterType.Whitelist local region = Region3.new(start.Position, finish.Position) local random = Random.new() for _, size in ipairs(PART_SIZES) do local descendants = {} for _ = 1, size do local newPart = Instance.new("Part") newPart.CFrame = hitbox.CFrame * CFrame.new( hitbox.Size.X * random:NextNumber(-0.5, 0.5), hitbox.Size.Y * random:NextNumber(-0.5, 0.5), hitbox.Size.Z * random:NextNumber(-0.5, 0.5) ) newPart.Anchored = true newPart.Size = Vector3.new(2, 2, 2) newPart.Transparency = 0.5 newPart.Color = Color3.fromRGB(255, 255, 255) newPart.Parent = Workspace table.insert(descendants, newPart) end -- add a random 25 parts to our FilterDescendantsInstances local filterDescendants = table.create(#descendants) for i = 1, math.min(size, 25) do table.insert(filterDescendants, descendants[i]) end overlap.FilterDescendantsInstances = descendants for i = 1, 2 do local useNewApi = i % 2 == 0 -- small wait before we perform benchmark for any expensive operations to finish task.wait(2) -- perform benchmark local start = os.clock() for _ = 1, 100 do if useNewApi then Workspace:GetPartBoundsInBox(hitboxCf, hitboxSz, overlap) else Workspace:FindPartsInRegion3(region) end end print(size, string.format("%0.4fms", (os.clock() - start) * 1000), useNewApi) end -- GC instances for _, part in ipairs(descendants) do part.Parent = nil end task.wait(5) end