Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Commit aef4434

Browse files
committed
Update NoFitRasterGpuCalculatorHelper.ts.
1 parent fdec9b5 commit aef4434

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

src/gpu/GPUHelper.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { GPU, GPUMode } from "gpu.js";
22
import { SimpleFormatting } from "../utils/SimpleFormatting";
33
import moment from "moment";
44

5-
export function time(name: string, func: () => any) {
5+
export function time(name: (result: any) => string, func: () => any) {
66
const start = new Date().getTime();
77

88
const result = func();
@@ -12,7 +12,7 @@ export function time(name: string, func: () => any) {
1212

1313
const now = SimpleFormatting.toFormattedDateTimeString(moment());
1414

15-
console.log(`[${now}] ${name} 用时${time}毫秒`);
15+
console.log(`[${now}] ${name(result)} 用时${time}毫秒`);
1616

1717
return result;
1818
}
@@ -51,8 +51,14 @@ function test() {
5151
.fill([])
5252
.map(() => Array<number>(k).fill(Math.random()));
5353

54-
const resultGPU = time(`GPU_${m}_${n}_${k}`, () => GPUHelper.test("gpu", m, n, k, a, b));
55-
const resultCPU = time(`CPU_${m}_${n}_${k}`, () => GPUHelper.test("cpu", m, n, k, a, b));
54+
const resultGPU = time(
55+
() => `GPU_${m}_${n}_${k}`,
56+
() => GPUHelper.test("gpu", m, n, k, a, b),
57+
);
58+
const resultCPU = time(
59+
() => `CPU_${m}_${n}_${k}`,
60+
() => GPUHelper.test("cpu", m, n, k, a, b),
61+
);
5662

5763
for (let i = 0; i < m; i++) {
5864
for (let j = 0; j < k; j++) {

src/gpu/NoFitRasterGpuCalculatorHelperServer.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ export class NoFitRasterGpuCalculatorHelperServer {
2525
const orbitingPolygon = JSON.parse(orbitingPolygonJson as any);
2626

2727
const result = time(
28-
`noFitPolygon:固定配件:${stationaryPolygon.length}个顶点,` +
29-
`自由配件:${orbitingPolygon.length}个顶点,`,
28+
(result: any) =>
29+
`noFitPolygon:固定配件:${stationaryPolygon.length}个顶点,` +
30+
`自由配件:${orbitingPolygon.length}个顶点,` +
31+
`结果:${result.length}个顶点,`,
3032
() =>
3133
noFitPolygon(
3234
stationaryPolygon.map((dot: any) => [dot.X, dot.Y]),
@@ -46,7 +48,8 @@ export class NoFitRasterGpuCalculatorHelperServer {
4648
const orbitingDotsMinimumPoint = JSON.parse(orbitingDotsMinimumPointJson as any);
4749

4850
const result = time(
49-
`noFitRaster:板材:${boardDots.length}个顶点,` +
51+
() =>
52+
`noFitRaster:板材:${boardDots.length}个顶点,` +
5053
`固定配件:${stationaryDots.length}个顶点,` +
5154
`自由配件:${orbitingDots.length}个顶点,`,
5255
() =>
@@ -67,11 +70,13 @@ export class NoFitRasterGpuCalculatorHelperServer {
6770
const a = JSON.parse(aJson as any);
6871
const b = JSON.parse(bJson as any);
6972

70-
const result = time(`rasterDifference,a:${a.length}个顶点,b:${b.length}个顶点,`, () =>
71-
NoFitRasterGpuCalculatorHelper.rasterDifference(
72-
a.map((dot: any) => [dot.X, dot.Y]),
73-
b.map((dot: any) => [dot.X, dot.Y]),
74-
),
73+
const result = time(
74+
(result) => `rasterDifference,a:${a.length}个顶点,b:${b.length}个顶点,结果:${result.length}个顶点`,
75+
() =>
76+
NoFitRasterGpuCalculatorHelper.rasterDifference(
77+
a.map((dot: any) => [dot.X, dot.Y]),
78+
b.map((dot: any) => [dot.X, dot.Y]),
79+
),
7580
);
7681

7782
return res.json(result.map((dot: any) => ({ X: dot[0], Y: dot[1] })));

src/utils/Settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const gapBetweenDots: number = 5.0;
1+
export const gapBetweenDots: number = 3.0;

0 commit comments

Comments
 (0)