-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0abc15
commit 657fba7
Showing
7 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
packages/chili/src/commands/application/performanceTest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
EditableGeometryEntity, | ||
GeometryModel, | ||
IApplication, | ||
ICommand, | ||
IDocument, | ||
Material, | ||
Plane, | ||
XYZ, | ||
command, | ||
} from "chili-core"; | ||
|
||
export abstract class PerformanceTestCommand implements ICommand { | ||
protected size = 10; | ||
protected gap = 1; | ||
protected rowCols = 20; | ||
|
||
async execute(app: IApplication): Promise<void> { | ||
let document = await app.newDocument("OCC Performace Test"); | ||
let lightGray = new Material(document, "LightGray", 0xdedede); | ||
let deepGray = new Material(document, "DeepGray", 0x898989); | ||
document.materials.push(lightGray, deepGray); | ||
|
||
const start = Date.now(); | ||
const distance = this.gap + this.size; | ||
for (let x = 0; x < this.rowCols; x++) { | ||
for (let y = 0; y < this.rowCols; y++) { | ||
for (let z = 0; z < this.rowCols; z++) { | ||
let position = XYZ.zero | ||
.add(XYZ.unitX.multiply(x * distance)) | ||
.add(XYZ.unitY.multiply(y * distance)) | ||
.add(XYZ.unitZ.multiply(z * distance)); | ||
this.createShape(document, lightGray, position); | ||
} | ||
} | ||
} | ||
console.log( | ||
`Create ${this.rowCols * this.rowCols * this.rowCols} shapes, Time: ${Date.now() - start} ms`, | ||
); | ||
} | ||
|
||
protected abstract createShape(document: IDocument, material: Material, position: XYZ): void; | ||
} | ||
|
||
@command({ | ||
name: "test.performace", | ||
display: "test.performace", | ||
icon: "", | ||
}) | ||
export class OccPerformanceTestCommand extends PerformanceTestCommand { | ||
private index = 1; | ||
|
||
protected override createShape(document: IDocument, material: Material, position: XYZ): void { | ||
let plane = Plane.XY.translateTo(position); | ||
let box = document.application.shapeFactory.box( | ||
plane, | ||
this.size * Math.random(), | ||
this.size * Math.random(), | ||
this.size * Math.random(), | ||
); | ||
let entity = new EditableGeometryEntity(document, box.unwrap(), material.id); | ||
let model = new GeometryModel(document, `box ${this.index++}`, entity); | ||
document.addNode(model); | ||
} | ||
} | ||
|
||
// export class ThreePerformanceTestCommand extends PerformanceTestCommand { | ||
|
||
// } |