-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ewitkon/expoTemplate
merge main
- Loading branch information
Showing
30 changed files
with
1,541 additions
and
1,740 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@osdk/foundry-sdk-generator": patch | ||
"@osdk/cli.cmd.typescript": patch | ||
"@osdk/shared.client.impl": patch | ||
"@osdk/shared.net": patch | ||
"@osdk/cli": patch | ||
--- | ||
|
||
Packages use more specific versions instead of indirection through shared.net |
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,5 @@ | ||
--- | ||
"@osdk/react": patch | ||
--- | ||
|
||
Adjusts dependencies on @osdk/client and @osdk/api to work with prerelease packages |
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,5 @@ | ||
--- | ||
"@osdk/create-app.template.react.beta": patch | ||
--- | ||
|
||
"Fixes dependency on OSDK" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
Currently, we only have one benchmark. | ||
|
||
``` | ||
cd tests/primary | ||
pnpm exec turbo bundle | ||
pnpm run benchmark | ||
cat build/benchmark/results.json | ||
``` | ||
|
||
example output: | ||
|
||
``` | ||
{ | ||
"tests": { | ||
"import.createClient.esbuild.js": { | ||
"runs": [ | ||
{ | ||
"type": "result", | ||
"time": 14.41, | ||
"heapUsed": 1362704, | ||
"rss": 1884160 | ||
}, | ||
..., | ||
{ | ||
"type": "result", | ||
"time": 14.66, | ||
"heapUsed": 1362680, | ||
"rss": 2392064 | ||
} | ||
], | ||
"stats": { | ||
"time": { | ||
"std": 0.6165480967090525, | ||
"mean": 14.905333333333335, | ||
"min": 14.41, | ||
"max": 16.7 | ||
}, | ||
"heapUsed": { | ||
"std": 41.845429857990474, | ||
"mean": 1362665.6, | ||
"min": 1362632, | ||
"max": 1362752 | ||
}, | ||
"rss": { | ||
"std": 243298.56906823127, | ||
"mean": 2170333.8666666667, | ||
"min": 1818624, | ||
"max": 2506752 | ||
} | ||
} | ||
}, | ||
"import.createClient.js": { | ||
"runs": [ | ||
{ | ||
"type": "result", | ||
"time": 36.3, | ||
"heapUsed": 2090960, | ||
"rss": 5619712 | ||
}, | ||
..., | ||
{ | ||
"type": "result", | ||
"time": 38.81, | ||
"heapUsed": 2094352, | ||
"rss": 5996544 | ||
} | ||
], | ||
"stats": { | ||
"time": { | ||
"std": 1.561981078274923, | ||
"mean": 38.35466666666668, | ||
"min": 36.3, | ||
"max": 41.92 | ||
}, | ||
"heapUsed": { | ||
"std": 1157.6154494860928, | ||
"mean": 2092049.0666666667, | ||
"min": 2090744, | ||
"max": 2094352 | ||
}, | ||
"rss": { | ||
"std": 326074.07364803203, | ||
"mean": 5936469.333333333, | ||
"min": 5505024, | ||
"max": 6602752 | ||
} | ||
} | ||
}, | ||
"noop.js": { | ||
"runs": [ | ||
{ | ||
"type": "result", | ||
"time": 0.01, | ||
"heapUsed": 1368, | ||
"rss": 81920 | ||
}, | ||
..., | ||
{ | ||
"type": "result", | ||
"time": 0.01, | ||
"heapUsed": 1368, | ||
"rss": 49152 | ||
} | ||
], | ||
"stats": { | ||
"time": { | ||
"std": 0.012220201853215573, | ||
"mean": 0.018000000000000002, | ||
"min": 0.01, | ||
"max": 0.06 | ||
}, | ||
"heapUsed": { | ||
"std": 0, | ||
"mean": 1368, | ||
"min": 1368, | ||
"max": 1368 | ||
}, | ||
"rss": { | ||
"std": 50410.207135724675, | ||
"mean": 32768, | ||
"min": 0, | ||
"max": 180224 | ||
} | ||
} | ||
} | ||
}, | ||
"sizes": { | ||
"esbuild/bundle.js": 128543 | ||
} | ||
} | ||
``` |
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,32 @@ | ||
{ | ||
"name": "@osdk/benchmarks.primary", | ||
"private": true, | ||
"version": "0.0.0", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/palantir/osdk-ts.git" | ||
}, | ||
"scripts": { | ||
"benchmark": "node --allow-natives-syntax src/benchmark.js", | ||
"bundle:esbuild": "esbuild src/bundle.js --bundle --platform=node --target=node18 --format=esm --outfile=build/esbuild/bundle.js --external:isomorphic-ws --external:fetch-retry" | ||
}, | ||
"dependencies": { | ||
"@osdk/client": "workspace:*" | ||
}, | ||
"peerDependencies": { | ||
"fetch-retry": "*", | ||
"isomorphic-ws": "*" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^22", | ||
"cli-progress": "^3.12.0", | ||
"esbuild": "^0.24.0", | ||
"execa": "^9.5.1", | ||
"express": "^4.21.1", | ||
"fast-deep-equal": "3.1.3", | ||
"mathjs": "^14.0.0", | ||
"tiny-invariant": "^1.3.3" | ||
}, | ||
"type": "module" | ||
} |
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,175 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// @ts-check | ||
|
||
import cliProgress from "cli-progress"; | ||
import { execaNode } from "execa"; | ||
import { mean, std } from "mathjs"; | ||
import * as fs from "node:fs/promises"; | ||
import * as path from "node:path"; | ||
import invariant from "tiny-invariant"; | ||
import { fixDirname } from "./helpers.js"; | ||
|
||
fixDirname(import.meta); | ||
|
||
const WARMUP_ITERATIONS = 1; | ||
const ITERATIONS = 10; | ||
|
||
async function main() { | ||
const multiBar = new cliProgress.MultiBar( | ||
{ | ||
format: "[{bar}] {percentage}% | ETA: {eta}s | {value}/{total} | {name}", | ||
clearOnComplete: true, | ||
}, | ||
cliProgress.Presets.shades_classic, | ||
); | ||
|
||
const tests = [ | ||
"createObjects.js", | ||
"import.createClient.esbuild.js", | ||
"import.createClient.js", | ||
"noop.js", | ||
]; | ||
|
||
const overallBar = multiBar.create( | ||
tests.length * (WARMUP_ITERATIONS + ITERATIONS), | ||
0, | ||
{ name: "Overall" }, | ||
); | ||
|
||
const final = { | ||
tests: {}, | ||
sizes: {}, | ||
}; | ||
|
||
for (const test of tests) { | ||
const progressBar = multiBar.create(WARMUP_ITERATIONS + ITERATIONS, 0, { | ||
name: test, | ||
}); | ||
for (let i = 0; i < WARMUP_ITERATIONS; i++) { | ||
await runTest(test); | ||
progressBar.increment(); | ||
overallBar.increment(); | ||
} | ||
|
||
const results = []; | ||
for (let i = 0; i < ITERATIONS; i++) { | ||
const result = await runTest(test); | ||
results.push(result); | ||
progressBar.increment(); | ||
overallBar.increment(); | ||
} | ||
|
||
const combinedResults = Object.fromEntries( | ||
["time", "heapUsed", "rss"].map((key) => [ | ||
key, | ||
{ | ||
std: std(results.map((x) => x[key]), "uncorrected"), | ||
mean: mean(results.map((x) => x[key])), | ||
min: Math.min(...results.map((x) => x[key])), | ||
max: Math.max(...results.map((x) => x[key])), | ||
}, | ||
]), | ||
); | ||
|
||
final.tests[test] = { | ||
runs: results, | ||
stats: combinedResults, | ||
}; | ||
} | ||
multiBar.stop(); | ||
|
||
const esBuildStats = await fs.stat( | ||
path.join(import.meta.dirname, "..", "build", "esbuild", "bundle.js"), | ||
); | ||
final.sizes["esbuild/bundle.js"] = esBuildStats.size; | ||
|
||
const outDir = path.join(import.meta.dirname, "..", "build", "benchmark"); | ||
await fs.mkdir(outDir, { recursive: true }); | ||
await fs.writeFile( | ||
path.join(outDir, "results.json"), | ||
JSON.stringify(final, null, 2), | ||
); | ||
} | ||
|
||
/** | ||
* @param {string} test | ||
* @returns {Promise<import("./types.js").Result>} | ||
*/ | ||
async function runTest(test) { | ||
const closeSidecar = await createSidecar(test); | ||
|
||
try { | ||
const subprocess = execaNode({ | ||
nodeOptions: [ | ||
"--allow-natives-syntax", | ||
"--expose-gc", | ||
// "--max-old-space-size=10", | ||
], | ||
ipc: true, | ||
})`${path.join(import.meta.dirname, "tests", test)}`; | ||
try { | ||
await subprocess.sendMessage({ "type": "start" }); | ||
|
||
/** @type {import("./types.js").Result} */ | ||
const response = /** @type any */ (await subprocess.getOneMessage()); | ||
invariant( | ||
response.type === "result" && "time" in response | ||
&& "heapUsed" in response | ||
&& "rss" in response, | ||
); | ||
return response; | ||
} catch (e) { | ||
console.log(e); | ||
console.log((await subprocess).code); | ||
// console.log(subprocess.stdout); | ||
// console.log(subprocess.stderr); | ||
throw e; | ||
} | ||
} finally { | ||
if (closeSidecar) { | ||
await closeSidecar(); | ||
} | ||
} | ||
} | ||
|
||
main(); | ||
|
||
async function createSidecar(test) { | ||
const sidecarPath = path.join(import.meta.dirname, "sidecars", test); | ||
|
||
const createSidecar = await fileExists(sidecarPath) | ||
? (await import(sidecarPath)).default | ||
: undefined; | ||
|
||
/** @type {undefined | (() => Promise<void>)} */ | ||
const closeSidecar = createSidecar ? await createSidecar() : undefined; | ||
return closeSidecar; | ||
} | ||
|
||
async function fileExists(filePath) { | ||
try { | ||
await fs.access(filePath); | ||
return true; | ||
} catch (err) { | ||
if (err.code === "ENOENT") { | ||
return false; | ||
} else { | ||
throw err; // Rethrow other errors | ||
} | ||
} | ||
} |
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,19 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { createClient } from "@osdk/client"; | ||
|
||
export { createClient }; |
Oops, something went wrong.