Add types to scripts and config files (#1277)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1277 Now that we have some TypeScript infra set up, move scripts (mainly the benchmarking one) and config files to TypeScript. Starts to move away a bit from the magic globals used in the JS environment. Reviewed By: yungsters Differential Revision: D45511176 fbshipit-source-id: 09bb1117a1b331758ed9d210e82d5b250577df81
This commit is contained in:
committed by
Facebook GitHub Bot
parent
19aed1d63e
commit
44ea3c1555
@@ -5,6 +5,9 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import { getMeasureCounter } from "../tools/MeasureCounter";
|
||||
import { Yoga, YGBENCHMARK } from "../tools/globals";
|
||||
|
||||
const ITERATIONS = 2000;
|
||||
|
||||
YGBENCHMARK("Stack with flex", () => {
|
||||
@@ -12,7 +15,7 @@ YGBENCHMARK("Stack with flex", () => {
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const measureCounter = getMeasureCounter(Yoga);
|
||||
const measureCounter = getMeasureCounter();
|
||||
|
||||
for (let i = 0; i < ITERATIONS; i++) {
|
||||
const child = Yoga.Node.create();
|
||||
@@ -21,14 +24,14 @@ YGBENCHMARK("Stack with flex", () => {
|
||||
root.insertChild(child, 0);
|
||||
}
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
||||
root.freeRecursive();
|
||||
});
|
||||
|
||||
YGBENCHMARK("Align stretch in undefined axis", () => {
|
||||
const root = Yoga.Node.create();
|
||||
|
||||
const measureCounter = getMeasureCounter(Yoga);
|
||||
const measureCounter = getMeasureCounter();
|
||||
|
||||
for (let i = 0; i < ITERATIONS; i++) {
|
||||
const child = Yoga.Node.create();
|
||||
@@ -37,14 +40,14 @@ YGBENCHMARK("Align stretch in undefined axis", () => {
|
||||
root.insertChild(child, 0);
|
||||
}
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
||||
root.freeRecursive();
|
||||
});
|
||||
|
||||
YGBENCHMARK("Nested flex", () => {
|
||||
const root = Yoga.Node.create();
|
||||
|
||||
const measureCounter = getMeasureCounter(Yoga);
|
||||
const measureCounter = getMeasureCounter();
|
||||
|
||||
const iterations = Math.pow(ITERATIONS, 1 / 2);
|
||||
|
||||
@@ -61,7 +64,7 @@ YGBENCHMARK("Nested flex", () => {
|
||||
}
|
||||
}
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
||||
root.freeRecursive();
|
||||
});
|
||||
|
||||
@@ -104,6 +107,6 @@ YGBENCHMARK("Huge nested layout", () => {
|
||||
}
|
||||
}
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
||||
root.freeRecursive();
|
||||
});
|
Reference in New Issue
Block a user