Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelEstes committed Aug 2, 2024
1 parent 726fdb5 commit dafe816
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 94 deletions.
110 changes: 57 additions & 53 deletions resources.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/benchmarks/avatarBenchmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function AvatarBenchmarkEntry() {
const sceneEntity = useRouteScene()
return sceneEntity ? (
<>
<AvatarBenchmark rootEntity={sceneEntity} onComplete={undefined as any} />
<AvatarBenchmark rootEntity={sceneEntity} onComplete={() => {}} />
<ProfilerUI systemUUIDs={[SkinnedMeshTransformSystem, AvatarAnimationSystem]} />
</>
) : null
Expand Down
2 changes: 1 addition & 1 deletion src/benchmarks/avatarIKBenchmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function AvatarIKBenchmarkEntry() {
const sceneEntity = useRouteScene()
return sceneEntity ? (
<>
<AvatarIKBenchmark rootEntity={sceneEntity} onComplete={undefined as any} />
<AvatarIKBenchmark rootEntity={sceneEntity} onComplete={() => {}} />
<ProfilerUI systemUUIDs={[SkinnedMeshTransformSystem]} />
</>
) : null
Expand Down
2 changes: 1 addition & 1 deletion src/benchmarks/particlesBenchmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function ParticlesBenchmarkEntry() {
const sceneEntity = useRouteScene()
return sceneEntity ? (
<>
<ParticlesBenchmark rootEntity={sceneEntity} onComplete={undefined as any} />
<ParticlesBenchmark rootEntity={sceneEntity} onComplete={() => {}} />
<ProfilerUI systemUUIDs={[ParticleSystem]} />
</>
) : null
Expand Down
2 changes: 1 addition & 1 deletion src/benchmarks/physicsBenchmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function PhysicsBenchmarkEntry() {
const sceneEntity = useRouteScene()
return sceneEntity ? (
<>
<PhysicsBenchmark rootEntity={sceneEntity} onComplete={undefined as any} />
<PhysicsBenchmark rootEntity={sceneEntity} onComplete={() => {}} />
<ProfilerUI systemUUIDs={[PhysicsSystem, PhysicsPreTransformSystem]} />
</>
) : null
Expand Down
12 changes: 6 additions & 6 deletions src/benchmarks/utils/profilerUI.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ECSState, System, SystemUUID, filterAndSortSystemsByAvgDuration } from '@etherealengine/ecs'
import { getState } from '@etherealengine/hyperflux'
import React, { useEffect, useState } from 'react'
import { ProfileState, SystemProfileData } from '../../engine/benchmarks/Profiling'
import { ProfileState, SystemProfileData, SystemProfilerSystem } from '../../engine/benchmarks/Profiling'

import('../../engine/benchmarks/Profiling')

Expand All @@ -18,7 +18,7 @@ export default function ProfilerUI(props: { systemUUIDs: SystemUUID[] }) {

SetSortedSystemProfileData(
filterAndSortSystemsByAvgDuration(0.2)
.filter((system) => system.uuid !== 'eepro.eetest.SystemProfilerSystem')
.filter((system) => system.uuid !== SystemProfilerSystem)
.slice(0, 6)
)
SetSystemProfileData(
Expand All @@ -43,23 +43,23 @@ export default function ProfilerUI(props: { systemUUIDs: SystemUUID[] }) {
{'Benchmarked Systems: '}
{systemProfileData.map((profileData) => {
return (
<>
<React.Fragment key={profileData.uuid}>
<div>{`System: ${profileData.uuid}`}</div>
<div>{`avg: ${Math.trunc(profileData.avgDuration * 1000) / 1000}ms \n max: ${
Math.trunc(profileData.maxDuration * 1000) / 1000
}ms`}</div>
</>
</React.Fragment>
)
})}
</div>
<div style={{ paddingTop: '18px' }}>
{'Longest Running Systems: '}
{sortedSystemProfileData.map((system) => {
return (
<>
<React.Fragment key={system.uuid}>
<div>{`System: ${system.uuid}`}</div>
<div>{`avg: ${Math.trunc(system.avgSystemDuration * 1000) / 1000}ms`}</div>
</>
</React.Fragment>
)
})}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/engine/benchmarks/AvatarBenchmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const AvatarBenchmark = (props: { rootEntity: Entity; onComplete: () => v
}, [avatars])

useEffect(() => {
if (onComplete && completedCount.value == avatarsToCreate) sleep(benchmarkWaitTime).then(onComplete)
if (completedCount.value == avatarsToCreate) sleep(benchmarkWaitTime).then(onComplete)
}, [completedCount.value == avatarsToCreate])

return (
Expand Down
17 changes: 3 additions & 14 deletions src/engine/benchmarks/ParticlesBenchmark.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
import {
Engine,
Entity,
EntityUUID,
UUIDComponent,
createEntity,
getComponent,
removeEntity,
setComponent
} from '@etherealengine/ecs'
import { Engine, Entity, getComponent, removeEntity, setComponent } from '@etherealengine/ecs'
import { ParticleSystemComponent } from '@etherealengine/engine/src/scene/components/ParticleSystemComponent'
import { TransformComponent } from '@etherealengine/spatial'
import { Object3DComponent } from '@etherealengine/spatial/src/renderer/components/Object3DComponent'
import { VisibleComponent } from '@etherealengine/spatial/src/renderer/components/VisibleComponent'
import { EntityTreeComponent } from '@etherealengine/spatial/src/transform/components/EntityTree'
import { useEffect } from 'react'
import { Group, MathUtils } from 'three'
import { setupEntity } from '../../examples/utils/common/entityUtils'

const objectsToCreate = 30
const waitTimeBetween = 200
const simulateTime = 3000

const createParticleEntity = (rootEntity: Entity) => {
const entity = createEntity()
const entity = setupEntity(rootEntity)

const position = getComponent(Engine.instance.cameraEntity, TransformComponent).position.clone()
position.setZ(position.z - 7.0)
position.setX(position.x + MathUtils.randFloat(-2.0, 2.0))
const obj3d = new Group()
obj3d.entity = entity
setComponent(entity, UUIDComponent, MathUtils.generateUUID() as EntityUUID)
setComponent(entity, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(entity, Object3DComponent, obj3d)
setComponent(entity, TransformComponent, { position })
setComponent(entity, ParticleSystemComponent)
Expand Down
17 changes: 3 additions & 14 deletions src/engine/benchmarks/PhysicsBenchmark.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import {
Engine,
Entity,
EntityUUID,
UUIDComponent,
createEntity,
getComponent,
removeEntity,
setComponent
} from '@etherealengine/ecs'
import { Engine, Entity, getComponent, removeEntity, setComponent } from '@etherealengine/ecs'
import { PrimitiveGeometryComponent } from '@etherealengine/engine/src/scene/components/PrimitiveGeometryComponent'
import { GeometryTypeEnum } from '@etherealengine/engine/src/scene/constants/GeometryTypeEnum'
import { TransformComponent } from '@etherealengine/spatial'
import { ColliderComponent } from '@etherealengine/spatial/src/physics/components/ColliderComponent'
import { RigidBodyComponent } from '@etherealengine/spatial/src/physics/components/RigidBodyComponent'
import { Object3DComponent } from '@etherealengine/spatial/src/renderer/components/Object3DComponent'
import { VisibleComponent } from '@etherealengine/spatial/src/renderer/components/VisibleComponent'
import { EntityTreeComponent } from '@etherealengine/spatial/src/transform/components/EntityTree'
import { useEffect } from 'react'
import { Group, MathUtils, Vector3 } from 'three'
import { setupEntity } from '../../examples/utils/common/entityUtils'

const objectsToCreate = 60
const waitTimeBetween = 200
Expand All @@ -26,15 +17,13 @@ const simulateTime = 3000
const scale = new Vector3(0.5, 0.5, 0.5)

const createPhysicsEntity = (rootEntity: Entity) => {
const entity = createEntity()
const entity = setupEntity(rootEntity)

const position = getComponent(Engine.instance.cameraEntity, TransformComponent).position.clone()
position.setZ(position.z - 7.0)
position.setX(position.x + MathUtils.randFloat(-2.0, 2.0))
const obj3d = new Group()
obj3d.entity = entity
setComponent(entity, UUIDComponent, MathUtils.generateUUID() as EntityUUID)
setComponent(entity, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(entity, Object3DComponent, obj3d)
setComponent(entity, TransformComponent, { position, scale })
setComponent(entity, PrimitiveGeometryComponent, {
Expand Down
4 changes: 2 additions & 2 deletions src/engine/benchmarks/Profiling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const execute = () => {

const data = {}
for (const system of systems) {
if (system.uuid == 'eepro.eetest.SystemProfilerSystem') continue
if (system.uuid === SystemProfilerSystem) continue
const max = systemDataMap[system.uuid].value ? systemDataMap[system.uuid].maxDuration.value : 0
data[system.uuid] = {
avgDuration: system.avgSystemDuration,
Expand All @@ -59,7 +59,7 @@ const execute = () => {
systemDataMap.merge(data)
}

export default defineSystem({
export const SystemProfilerSystem = defineSystem({
uuid: 'eepro.eetest.SystemProfilerSystem',
execute,
insert: { after: PresentationSystemGroup }
Expand Down

0 comments on commit dafe816

Please sign in to comment.