mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Refactor stress test files to enhance clarity and performance
- Removed unnecessary references to LargeTreeGenerator in multiple stress test files, streamlining the code. - Simplified loop iterations by replacing index variables with underscores for unused values, improving readability. - Updated the diff logic in the reify and diff tests to eliminate unused patch variables, enhancing performance and clarity. - Ensured consistent formatting across stress test files for better maintainability.
This commit is contained in:
parent
d513ab16c0
commit
09a0f95d53
8 changed files with 12 additions and 20 deletions
|
|
@ -7,8 +7,6 @@
|
|||
return function()
|
||||
local PatchSet = require(script.Parent.PatchSet)
|
||||
local InstanceMap = require(script.Parent.InstanceMap)
|
||||
local testUtils = require(script.Parent.testUtils)
|
||||
local PatchGenerator = testUtils.PatchGenerator
|
||||
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ return function()
|
|||
local PatchSet = require(script.Parent.Parent.PatchSet)
|
||||
local testUtils = require(script.Parent.Parent.testUtils)
|
||||
local PatchGenerator = testUtils.PatchGenerator
|
||||
local LargeTreeGenerator = testUtils.LargeTreeGenerator
|
||||
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ return function()
|
|||
|
||||
-- Fix up children references
|
||||
for id, virt in pairs(virtualInstances) do
|
||||
for i, childPlaceholder in ipairs(virt.Children) do
|
||||
for i, _ in ipairs(virt.Children) do
|
||||
-- Find the actual child ID
|
||||
for otherId, otherVirt in pairs(virtualInstances) do
|
||||
if otherVirt.Parent == id then
|
||||
|
|
@ -529,7 +529,7 @@ return function()
|
|||
},
|
||||
}
|
||||
|
||||
local ok, patch = diff(instanceMap, virtualInstances, rootId)
|
||||
local ok, _ = diff(instanceMap, virtualInstances, rootId)
|
||||
|
||||
expect(ok).to.equal(true)
|
||||
-- CFrame decoding might not work in test env, but the test structure is valid
|
||||
|
|
@ -957,7 +957,7 @@ return function()
|
|||
},
|
||||
}
|
||||
|
||||
local ok, patch = diff(instanceMap, virtualInstances, rootId)
|
||||
local ok, _ = diff(instanceMap, virtualInstances, rootId)
|
||||
|
||||
expect(ok).to.equal(true)
|
||||
-- Should be considered equal
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ return function()
|
|||
local PatchSet = require(script.Parent.Parent.PatchSet)
|
||||
local InstanceMap = require(script.Parent.Parent.InstanceMap)
|
||||
local testUtils = require(script.Parent.Parent.testUtils)
|
||||
local LargeTreeGenerator = testUtils.LargeTreeGenerator
|
||||
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
|
|
@ -43,11 +42,9 @@ return function()
|
|||
-- Build virtual instances for 20-level deep tree
|
||||
local parentId = nil
|
||||
local rootId = nil
|
||||
local ids = {}
|
||||
|
||||
for i = 1, 20 do
|
||||
local id = generateId()
|
||||
table.insert(ids, id)
|
||||
|
||||
if rootId == nil then
|
||||
rootId = id
|
||||
|
|
@ -271,7 +268,7 @@ return function()
|
|||
local children = {}
|
||||
local invalidIds = {}
|
||||
|
||||
for i = 1, 5 do
|
||||
for _ = 1, 5 do
|
||||
local childId = generateId()
|
||||
table.insert(children, childId)
|
||||
table.insert(invalidIds, childId)
|
||||
|
|
@ -519,7 +516,7 @@ return function()
|
|||
describe("performance", function()
|
||||
it("should create 200+ instances in reasonable time", function()
|
||||
local instanceMap = InstanceMap.new()
|
||||
local treeData = LargeTreeGenerator.createVirtualTree({
|
||||
local treeData = testUtils.LargeTreeGenerator.createVirtualTree({
|
||||
depth = 3,
|
||||
width = 6, -- 6^3 = 216 instances
|
||||
instanceType = "Folder",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ return function()
|
|||
local applyPatch = require(script.Parent.Parent.Reconciler.applyPatch)
|
||||
local diff = require(script.Parent.Parent.Reconciler.diff)
|
||||
local testUtils = require(script.Parent.Parent.testUtils)
|
||||
local LargeTreeGenerator = testUtils.LargeTreeGenerator
|
||||
local PatchGenerator = testUtils.PatchGenerator
|
||||
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
|
@ -47,7 +46,7 @@ return function()
|
|||
local rootId = generateId()
|
||||
instanceMap:insert(rootId, root)
|
||||
|
||||
for i = 1, 50 do
|
||||
for _ = 1, 50 do
|
||||
-- Add
|
||||
local addPatch = PatchGenerator.createAdditionsPatch({
|
||||
count = 5,
|
||||
|
|
@ -86,7 +85,7 @@ return function()
|
|||
|
||||
local allIds = {}
|
||||
|
||||
for i = 1, 30 do
|
||||
for _ = 1, 30 do
|
||||
-- Add some
|
||||
local addPatch = PatchGenerator.createAdditionsPatch({
|
||||
count = 3,
|
||||
|
|
@ -101,7 +100,7 @@ return function()
|
|||
-- Remove some (if we have any)
|
||||
if #allIds > 5 then
|
||||
local toRemove = {}
|
||||
for j = 1, 2 do
|
||||
for _ = 1, 2 do
|
||||
if #allIds > 0 then
|
||||
table.insert(toRemove, table.remove(allIds, 1))
|
||||
end
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ return function()
|
|||
instanceMap:insert(rootId, root)
|
||||
|
||||
-- Apply 10 consecutive patches
|
||||
for i = 1, 10 do
|
||||
for _ = 1, 10 do
|
||||
local patch = PatchGenerator.createAdditionsPatch({
|
||||
count = 5,
|
||||
parentId = rootId,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ return function()
|
|||
local InstanceMap = require(script.Parent.Parent.InstanceMap)
|
||||
local PatchSet = require(script.Parent.Parent.PatchSet)
|
||||
local applyPatch = require(script.Parent.Parent.Reconciler.applyPatch)
|
||||
local diff = require(script.Parent.Parent.Reconciler.diff)
|
||||
local encodeInstance = require(script.Parent.Parent.ChangeBatcher.encodeInstance)
|
||||
local testUtils = require(script.Parent.Parent.testUtils)
|
||||
local PatchGenerator = testUtils.PatchGenerator
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ function LargeTreeGenerator.createInstanceTree(options)
|
|||
local withDuplicates = options.withDuplicates or false
|
||||
local duplicateCount = options.duplicateCount or 2
|
||||
|
||||
local function createInstance(name, level)
|
||||
local function createInstance(name, _level)
|
||||
local className = instanceType
|
||||
if instanceType == "mixed" then
|
||||
className = LargeTreeGenerator.randomInstanceType()
|
||||
|
|
@ -103,7 +103,7 @@ function LargeTreeGenerator.createInstanceTree(options)
|
|||
|
||||
-- Optionally create duplicates
|
||||
if withDuplicates and currentDepth <= 2 then -- Only add duplicates at top levels
|
||||
for i = 1, duplicateCount do
|
||||
for _ = 1, duplicateCount do
|
||||
local duplicateName = prefix .. "_1" -- Same name as first child
|
||||
local duplicate = createInstance(duplicateName, currentDepth)
|
||||
duplicate.Parent = parent
|
||||
|
|
@ -240,7 +240,7 @@ end
|
|||
]]
|
||||
function LargeTreeGenerator.countInstances(root)
|
||||
local count = 1 -- Count the root
|
||||
for _, child in ipairs(root:GetDescendants()) do
|
||||
for _ in ipairs(root:GetDescendants()) do
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue